Beispiel #1
0
def queue(filename):
    """ queue(filename) -> None
    queue a music file to follow the current
    """
    check_mixer()
    global _queue_music
    try:
        filename = rwops_encode_file_path(filename)
        _queue_music = sdl.Mix_LoadMUS(filename)
    except SDLError:
        # try as file object
        rwops = rwops_from_file(filename)
        _queue_music = sdl.Mix_LoadMUS_RW(rwops)

    if not _queue_music:
        raise SDLError.from_sdl_error()
Beispiel #2
0
def load(obj):
    """load(filename): return None
       load(object): return None

       Load a music file for playback"""
    check_mixer()
    global _current_music, _queue_music
    if isinstance(obj, (bytes_, unicode_)):
        filename = rwops_encode_file_path(obj)
        new_music = sdl.Mix_LoadMUS(filename)
    else:
        rwops = rwops_from_file(obj)
        new_music = sdl.Mix_LoadMUS_RW(rwops)
    if not new_music:
        raise SDLError.from_sdl_error()

    # Cleanup
    if _current_music:
        sdl.Mix_FreeMusic(_current_music)
    if _queue_music:
        sdl.Mix_FreeMusic(_queue_music)
        _queue_music = None

    _current_music = new_music