Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to playback .mp3 file in WTK

 
chetan dhewal
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to play the mp3 file in WTK 2.1... I am unable to do so. I am able to play only the .wav and .midi files.
I am using only the media API in the MIDP , i m not using the MM API.

heres the code
------------------------------

public class m4 extends MIDlet
{
public m4()
{
}


public void startApp()
{
try
{

InputStream is=getClass().getResourceAsStream("a.mp3");
Player p = Manager.createPlayer(is,"audio/mpeg");
p.realize();
p.prefetch();
p.start();

}
catch(Exception e)
{
}

}

public void pauseApp()
{
}

public void destroyApp(boolean x)
{
}

}
------------------------------


Thnx
Chetan Dhewal
SCJP 1.2
 
Theodore Casser
Ranch Hand
Posts: 1902
Hibernate Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're asking in the wrong forum - you really should look at the J2ME forum higher up in the listing.
 
Sathya Srinivasan
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remember right, default MIDP API supports only tones and MIDI. If you need to play MP3, you need to have the appropriate Java codec to play it. You'll probably have to initialize it using Player or Manager classes. There is no out-of-the-box support for MP3 in MIDP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic