javax.microedition.media package is introduced in MIDP2.0 profile. This package supports sound and upward compatibility with MultiMedia API.It has Manager, Player and Control as main objects.Different audio files, from various locations can be played on mobile.

Simple Media Playback

 
 try
  { 
    Player p = Manager.createPlayer("http://webserver/music.wav");
    p.start(); 
  } 
  catch (IOException ioe) { } 
  catch (MediaException me) { } 

Playing Back from Media Stored in JAR
  try 
  { 
    InputStream is = getClass().getResourceAsStream("music.wav"); 
    Player p = Manager.createPlayer(is, "audio/X-wav"); 
    p.start(); 
  }
  catch (IOException ioe) { } 
  catch (MediaException me) { } 

 


 

 Related Tips