Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.audio

Class EM_MUSIC_PLAYER


Direct ancestors

EM_SHARED_SUBSYSTEMS, EM_SHARED_AUDIO_FACTORY, EM_AUDIO_CONSTANTS, EM_TIME_SINGLETON, SDL_MIXER_FUNCTIONS_EXTERNAL, MEMORY

Creation

Features

Invariants

indexing

description

Implements a simple music player.

This player can play either WAVE, MOD, MIDI, OGG or MP3.

Use this player if you don't want to handle all sound stuff
by your own. This player let's you play music files in a very
very easy way.

This class was designed for having music support in a hurry.
We recommend to use it whenever you need just to play music.

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

date

$Date: 2005/10/22 13:22:42 $

revision

$Revision: 1.19 $

class

EM_MUSIC_PLAYER

create

make_with_path (a_path: STRING; an_extension_list: DS_LINKED_LIST [STRING]; do_recursive_search: BOOLEAN; do_initialize_subsystem: BOOLEAN)

-- Make playlist from a_path searching for file with
-- extensions in an_extension_list.
--
-- If you want to search files also in subfolders, set
-- do_recursive_search to True.
--
-- This player may initialize the audio subsystem for you.
-- Use do_initialize_subsystem to have it enabled by this player.

require
a_path_not_void: a_path /= Void
make_with_list (a_list: DS_LINKED_LIST [STRING]; do_initialize_subsystem: BOOLEAN)

-- Make playlist from a_list.
--
-- This player may initialize the audio subsystem for you.
-- Use do_initialize_subsystem to have it enabled by this player.

make_with_file (a_filename: STRING; do_initialize_subsystem: BOOLEAN)

-- Make playlist with a_filename.
--
-- This player may initialize the audio subsystem for you.
-- Use do_initialize_subsystem to have it enabled by this player.

require
a_filename_not_void: a_filename /= Void
ensure
playlist_count_is_one: playlist.count = 1
make_empty (do_initialize_subsystem: BOOLEAN)

-- Make with an empty playlist.
--
-- This player may initialize the audio subsystem for you.
-- Use do_initialize_subsystem to have it enabled by this player.

ensure
playlist_count_is_zero: playlist.count = 0

feature -- Access

did_initialize_subsystem: BOOLEAN

-- Did this player initialize the audio subsystem?

is_paused: BOOLEAN

-- Is this player in paused mode?

is_playing: BOOLEAN

-- Is this Player playing a file?

music_playing: EM_MUSIC

-- Actually playing music
-- Note: File may already be deallocated!

playlist: EM_PLAYLIST

-- Playlist of this music player

repeat: BOOLEAN

-- Does playlist repeats playback?

shuffle: BOOLEAN

-- Does playlist plays shuffled?

volume: INTEGER

-- Returns current volume.

feature -- Removal

dispose

-- Disable audio subsystem if initialized before.

-- (From DISPOSABLE)

ensure then
subsystem_disabled: not audio_subsystem.is_enabled

feature -- Callback events

music_finished

-- Event is fired when music finishes playing.

feature -- Playback

back

-- Go to previous playlist entry and play it.

forth

-- Go to next playlist entry and play it.

pause

-- Pause playback.

require
music_set: music_playing /= Void
is_playing: not is_paused and is_playing
ensure
is_paused: is_paused
play

-- Play current playlist entry.

require
not_playing: not is_playing
ensure
play_i_th (an_index: INTEGER)

-- Play track at position an_index in playlist.

require
not_playing: not is_playing
index_valid: 1 <= an_index and then an_index <= playlist.count
ensure
resume

-- Resume playback.

require
music_set: music_playing /= Void
is_paused: is_paused
ensure
is_playing: not is_paused and is_playing
stop

-- Stop playing.

ensure
is_stopped: not music_playing.is_playing

feature -- Setters

set_repeat (do_repeat: like repeat)

-- Set repeat to do_repeat.

ensure
repeat_assigned: repeat = do_repeat
set_shuffle (do_shuffle: like shuffle)

-- Set shuffle to do_shuffle.

ensure
shuffle_assigned: shuffle = do_shuffle
set_volume (a_volume: like volume)

-- Set volume for player to a_volume.

ensure
volume_assigned: volume = a_volume

invariant

playlist_created: playlist /= Void
callback_receiver_created: callback_receiver /= Void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end