Audio Library

PreviousNext

Players

Overview

Players are the easiest method to play sound and/or music files. With them, you don't need to look up how things really work in the library. You can easily use them and play music and sounds. To play a music file, you have everything what you need in EM_MUSIC_PLAYER and for playing sound files, just use EM_SOUND_PLAYER.

Music player

EM_MUSIC_PLAYER implements a very simple music player. This player can play either WAVE, MOD, MIDI, OGG or MP3.

This class was designed for a quick music support. We recommend to use it whenever you need to play music without more control on the audio subsystem.

For creating the music player you got different options. You can use make_with_path, make_with_list, make_with_file or make_empty depending if you want to create your playlist from path, with a list, from a file or empty.

With the functions forth and back you can change your current position in the playlist.

Note: You need to have special compiled version of SDL_mixer to be able to play MP3 files. Please check MP3 support for further details.

Sound player

EM_SOUND_PLAYER implements a very simple sound player. This player can play either WAVE, AIFF, RIFF, OGG or VOC.

This class was designed for a quick sound support. We recommend to use it whenever you need to play sound without more control on the audio subsystem.

For creating the sound player you got different options. You can use make_with_path, make_with_list, make_with_file or make_empty depending if you want to create your playlist from path, with a list, from a file or empty.

You can play and stop a sound file from the channel by filename or by an_index from the playlist. You also got the possibility to find the channel where soundfile at an_index is playing or even remove the channel where soundfile at an_index is playing.

Notes

The audio subsystem can be enabled automatically for very easy usage. Just set do_initialize_subsystem to True when creating either EM_MUSIC_PLAYER or EM_SOUND_PLAYER with any of creation features.

Audio subsystem doesn't need to be disabled when initialized by any of the two players. If you let both players enable the subsystem, please be aware that only the first created player will initialize the subsystem and also disable it when freeing the object.