com.badlogic.gdx.audio
Interface Music

All Superinterfaces:
Disposable

public interface Music
extends Disposable

A Music instance represents a streamed audio file. The interface supports setting the play back position, pausing and resuming and so on. When you are done with using the Music instance you have to dispose it via the dispose() method.

Music instances are created via Audio.newMusic(FileHandle).

Music instances are automatically paused and resumed when an Application is paused or resumed. See ApplicationListener.

Note: any values provided will not be clamped, it is the developer's responsibility to do so

Author:
mzechner

Nested Class Summary
static interface Music.OnCompletionListener
          Interface definition for a callback to be invoked when playback of a music stream has completed.
 
Method Summary
 void dispose()
          Needs to be called when the Music is no longer needed.
 float getPosition()
          Returns the playback position in milliseconds.
 float getVolume()
           
 boolean isLooping()
           
 boolean isPlaying()
           
 void pause()
          Pauses the play back.
 void play()
          Starts the play back of the music stream.
 void setLooping(boolean isLooping)
          Sets whether the music stream is looping.
 void setOnCompletionListener(Music.OnCompletionListener listener)
          Register a callback to be invoked when the end of a music stream has been reached during playback.
 void setPan(float pan, float volume)
          Sets the panning and volume of this music stream.
 void setVolume(float volume)
          Sets the volume of this music stream.
 void stop()
          Stops a playing or paused Music instance.
 

Method Detail

play

void play()
Starts the play back of the music stream. In case the stream was paused this will resume the play back. In case the music stream is finished playing this will restart the play back.


pause

void pause()
Pauses the play back. If the music stream has not been started yet or has finished playing a call to this method will be ignored.


stop

void stop()
Stops a playing or paused Music instance. Next time play() is invoked the Music will start from the beginning.


isPlaying

boolean isPlaying()
Returns:
whether this music stream is playing

setLooping

void setLooping(boolean isLooping)
Sets whether the music stream is looping. This can be called at any time, whether the stream is playing.

Parameters:
isLooping - whether to loop the stream

isLooping

boolean isLooping()
Returns:
whether the music stream is playing.

setVolume

void setVolume(float volume)
Sets the volume of this music stream. The volume must be given in the range [0,1] with 0 being silent and 1 being the maximum volume.

Parameters:
volume -

getVolume

float getVolume()
Returns:
the volume of this music stream.

setPan

void setPan(float pan,
            float volume)
Sets the panning and volume of this music stream.

Parameters:
pan - panning in the range -1 (full left) to 1 (full right). 0 is center position.
volume - the volume in the range [0,1].

getPosition

float getPosition()
Returns the playback position in milliseconds.


dispose

void dispose()
Needs to be called when the Music is no longer needed.

Specified by:
dispose in interface Disposable

setOnCompletionListener

void setOnCompletionListener(Music.OnCompletionListener listener)
Register a callback to be invoked when the end of a music stream has been reached during playback.

Parameters:
listener - the callback that will be run.


Copyright © 2014. All Rights Reserved.