The following code should work on 90-95% of phones supporting JSR-135. Ordering all the calls to various methods is key to making it portable. This sounds local to your JAR. Any streaming sound would be another problem in general :)
InputStream inputStream = this.getClass().getResourceAsStream( musicFile );
musicPlayer = Manager.createPlayer( inputStream, musicEncoding );
musicPlayer.prefetch();
musicPlayer.addPlayerListener( this );
if( loopMusic )
{
musicPlayer.setLoopCount( -1 );
}
VolumeControl volumeControl =
(VolumeControl) musicPlayer.getControl( "VolumeControl" );
volumeControl.setLevel( curVolume );
musicPlayer.start();
volumeControl = (VolumeControl) musicPlayer.getControl( "VolumeControl" );
volumeControl.setLevel( curVolume );
inputStream.close();
inputStream = null;
source
share