libgdx API

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.

Author:
mzechner

Method Summary
 void dispose()
          Needs to be called when the Music is no longer needed.
 float getPosition()
          Returns the playback position in milliseconds.
 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 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 -

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

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)