Source code for arcade.sound

Sound library.

from platform import system
import typing
import pyglet

[docs]class Sound: def __init__(self, file_name: str): self.file_name = file_name self.player =
[docs] def play(self): if self.player.is_queued: player = else:
[docs]class PlaysoundException(Exception): pass
def _load_sound_library(): """ Special code for Windows so we grab the proper avbin from our directory. Otherwise hope the correct package is installed. """ # lazy loading if not _load_sound_library._sound_library_loaded: _load_sound_library._sound_library_loaded = True else: return import pyglet_ffmpeg pyglet_ffmpeg.load_ffmpeg() # Initialize static function variable _load_sound_library._sound_library_loaded = False
[docs]def load_sound(file_name: str): """ Load a sound """ sound = Sound(file_name) return sound
[docs]def play_sound(sound): """ Play a sound """
[docs]def stop_sound(sound: sound.pause()