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

em.audio

Class EM_SOUND_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 sound player.

This player can play either WAVE, AIFF, RIFF, OGG or VOC.

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

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

date

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

revision

$Revision: 1.19 $

class

EM_SOUND_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_valid: 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_valid: playlist.count = 0

feature -- Access

did_initialize_subsystem: BOOLEAN

-- Has the subsystem been initialized by the player?

is_i_th_playing (an_index: INTEGER): BOOLEAN

-- Is file with an_index playing?

playlist: EM_PLAYLIST

-- Playlist of the player.

volume: INTEGER

-- Volume of player

feature -- Removal

dispose

-- Disable audio subsystem if initialized before.

-- (From DISPOSABLE)

ensure then
subsystem_disabled: not audio_subsystem.is_enabled

feature -- Playback

play_file (a_filename: STRING; a_loop_count: INTEGER)

-- Play file at location a_filename for a_loop_count times.

play_i_th (an_index: INTEGER; a_loop_count: INTEGER)

-- Play item at position an_index in playlist for a_loop_count times.

require
valid_index: an_index >= 1 and then an_index <= playlist.count
stop_all

-- Stop all playing sound files.

stop_file (a_filename: STRING)

-- Stop playing file at location a_filename.

stop_i_th (an_index: INTEGER)

-- Stop playing file at position an_index.

require
valid_index: an_index >= 1 and then an_index <= playlist.count

feature -- Setters

set_volume (a_volume: like volume)

-- Set volume to a_volume.

ensure
volume_assigned: volume = a_volume

invariant

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

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

end