MMAPI(Mobile Media API) provides a framework for playing media content on J2ME devices.There are protocols defined for real-time streaming of Internet radio content, streaming other RTP (Real-time Transport Protocol) content, capturing audio, and taking pictures.

The method below plays a video file the on mobile device:

 public void run()
{
  try
  {
    String url = "http://server/video-mpeg.mpg";
    Player p = Manager.createPlayer(url);
    p.realize();

    //Get the video controller
    VideoControl video = (VideoControl) p.getControl("VideoControl");

    //Get a GUI to display the video
    Item videoItem = (Item)video.initDisplayMode(
    VideoControl.USE_GUI_PRIMITIVE, null);

    //Append the GUI to a form
    videoForm.append(videoItem);

    //Start the video
    p.start();
  }
  catch(Exception e)
  {}
}

 

If you want to play the video from an rtsp server, you only need to change url with "rtsp://server/video.mpg". This will only work on devices which support real time input streams.

 

 Related Tips