首页 arrow 会员博客 arrow Playing MP3 from your local file on J2ME devices
Playing MP3 from your local file on J2ME devices
Author Author: jacky | Date Date: 2008-03-14 | View Count View: 1318 | Section & Category 会员博客 - 个人博客 | Digg Digg: 0

MMAPI supports playing mp3 files. Depending upon the device capabilities and size of the mp3 files, an MP3 player can be created on J2ME phones.

You should note that not all phones support MP3 audio format. For eexample, Motorola/A1000 supports midi but not mp3 while E1000 supports both. 

The method below creates player and play mp3 file.

public void run()
{
  try
  {
    InputStream is = getClass().getResourceAsStream("/your.mp3");
    player = Manager.createPlayer(is,"audio/mpeg");

    player.realize();
    // get volume control for player and set volume to max
    vc = (VolumeControlplayer.getControl("VolumeControl");
    if(vc != null)
    {
      vc.setLevel(100);
    }
    player.prefetch();
    player.start();
  }
  catch(Exception e)
  {}
}

 


最近更新 ( 2008-03-14 )
 

尚无评论发表

我要发表评论

登录菜单

最新博客

本月热门

热门博客

订阅本站

RSS 0.91 RSS 1.0 RSS 2.0 ATOM 0.3 OPML