// loads the InputStream for the sound
InputStream inputStream = this.getClass().getResourceAsStream( musicFile );
// create the standard Player
musicPlayer = Manager.createPlayer( inputStream, musicEncoding );
musicPlayer.prefetch();
// add player listener to access sound events
musicPlayer.addPlayerListener( this );
if( loopMusic )
{
// use the loop count method for infinite looping
musicPlayer.setLoopCount( -1 );
}
// The set occurs twice to prevent sound spikes at the very
// beginning of the sound.
VolumeControl volumeControl =
(VolumeControl) musicPlayer.getControl( "VolumeControl" );
volumeControl.setLevel( curVolume );
// finally start the piece of music
musicPlayer.start()
We’ve updated our privacy policy so that we are compliant with changing global privacy regulations and to provide you with insight into the limited ways in which we use your data.
You can read the details below. By accepting, you agree to the updated privacy policy.