Source code for CoolWorld.sounds

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Sound management module.

Implements:

    class WorldSoundManager -- generic sound management class
    interface.
"""

"""
    The MIT License (MIT)

    Copyright (c) 2015 Raphaël SEBAN

    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation
    files (the "Software"), to deal in the Software without
    restriction, including without limitation the rights to use, copy,
    modify, merge, publish, distribute, sublicense, and/or sell copies
    of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
    BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
    ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
"""

try:
    from . import world
except:
    import world
# end try


[docs]class WorldSoundManager (world.WorldItem): """Generic sound management class interface. As a WorldItem subclass, this can be accessed through e.g. self.world.get("worldsoundmanager") or any other arbitrary name while registering. Current implementation is simply an interface and does nothing special, as each external lib has its own approach for sound management. Feel free to subclass this in order to best meet your own specific needs. """
[docs] def do_step (self, *args, **kw): """Do a game frame (step) - hook method. Called at each step of world game's main loop. Current implementation does nothing. Override this in subclasses whenever you need some action at each step of game loop. """ pass # end def
[docs] def finalize (self): """Finalize world item - hook method. Called after exiting world game's main loop. Current implementation does nothing. Override this in subclasses whenever you need some deletion or garbage collection at the end of the game (or at the end of world item's lifecycle). """ pass # end def
[docs] def initialize (self): """Initialize world item - hook method. Called just before entering world game's main loop. Current implementation does nothing. Override this in subclasses whenever you need some initializations at the beginning of the game (or at the beginning of world item's lifecycle). """ pass # end def
[docs] def pause_sound (self, *args, **kw): """Pause sound - hook method. This should be implemented along with each external lib specific approach. Call this method whenever a sound playback should be paused. """ pass # end def
[docs] def play_sound (self, *args, **kw): """Play sound - hook method. This should be implemented along with each external lib specific approach. Call this method whenever a new sound should be played. """ pass # end def
[docs] def resume_sound (self, *args, **kw): """Resume sound - hook method. This should be implemented along with each external lib specific approach. Call this method whenever a paused sound playback should be resumed. """ pass # end def
[docs] def stop_sound (self, *args, **kw): """Stop sound - hook method. This should be implemented along with each external lib specific approach. Call this method whenever a sound playback should be stopped. """ pass # end def # end class