code_junkie

How do I play a sound file in j2me on Samsung mobile phones?

Nov 11th, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. // Code starts here put this into midlet run() method
  2.  
  3. public void run()
  4. {
  5. try
  6. {
  7. InputStream is = getClass().getResourceAsStream("your_audio_file.mp3");
  8. player = Manager.createPlayer(is,"audio/mpeg");
  9.  
  10. // if "audio/mpeg" doesn't work try "audio/mp3"
  11.  
  12. player.realize();
  13. player.prefetch();
  14. player.start();
  15. }
  16. catch(Exception e)
  17. {}
  18. }
Add Comment
Please, Sign In to add comment