d2d.audio.music



enum float INV_MIX_MAX_VOLUME;
1.0 / MIX_MAX_VOLUME

enum FadingStatus: ubyte;


NoFading


FadingOut


FadingIn


enum MusicType: ubyte;


CommandBased


Wav


Mod


ModPlug


Mid


Ogg


Mp3


Mp3Mad


None


class Music: d2d.core.iverifiable.IVerifiable, d2d.core.idisposable.IDisposable;
Thin wrap around Mix_Music including loading [FLAC, MikMod, Ogg Vorbis, MP3, Wav] using SDL_Mixer.

@property Mix_Music* handle();
Handle to the
Mix_Music*
.

@property bool valid();
Checks if the handle is not null.

this(string path);
Loads a music file

static Music fromMusic(Mix_Music* handle);
Creates music from a
Mix_Music*
.

static @property string error();
Returns the latest sound related error

void dispose();
Deallocates the memory and invalidates
this
.

bool play(int loops = 1);
Plays this music, will stop other musics. -1 loops will play forever.

Returns:
true on success, or false on errors

bool fadeIn(int ms, int loops = 1);
Starts this music by fading in over
ms
milliseconds, will stop other musics. -1 loops will play forever.

Params:
int ms Milliseconds for the fade-in effect to complete.
int loops -1 loops will play forever. 0 plays the music zero times.

Returns:
true on success, or false on errors

bool fadeIn(int ms, int loops, double position);
Starts this music by fading in over
ms
milliseconds, will stop other musics.

Params:
int ms Milliseconds for the fade-in effect to complete.
int loops -1 loops will play forever. 0 plays the music zero times.
double position Set the position of the currently playing music. The position takes different meanings for different music sources. It only works on the music sources listed below.

MOD

The double is cast to Uint16 and used for a pattern number in the module. Passing zero is similar to rewinding the song.

OGG/MP3

Jumps to position seconds from the beginning of the song.

Returns:
true on success, or false on errors

@property MusicType type();


static @property bool position(double value);
Modifies the position where currently playing.

Params:
double value Set the position of the currently playing music. The position takes different meanings for different music sources. It only works on the music sources listed below. Will automatically rewind before setting.

MOD

The double is cast to Uint16 and used for a pattern number in the module. Passing zero is similar to rewinding the song.

OGG/MP3

Jumps to position seconds from the beginning of the song.

Returns:
true on success, or false if the codec doesn't support this function

static void rewind();
Rewinds music to the start. This is safe to use on halted, paused, and already playing music. It is not useful to rewind the music immediately after starting playback, because it starts at the beginning by default.

static void stop();
Halt playback of music. This interrupts music fader effects.

static void pause();
Pause the music playback. You may halt paused music.

Note:
Music can only be paused if it is actively playing.

static void resume();
Unpause the music. This is safe to use on halted, paused, and already playing music.

static @property float volume();
Returns the current volume as float in range 0.0 to 1.0

static @property void volume(float value);
Sets the current volume as float in range 0.0 to 1.0

static @property bool isPlaying();


static @property bool isPaused();


static @property FadingStatus fadingStatus();



Page generated by Ddoc.