0

I have downloaded the code of - Experiments in Streaming Content in Java ME by Vikram Goyal

But when trying to run the application, with emulator, after running the Darwin Stream Server I get the following error -

Midlet->startApp
StreamingDataSource->StreamingDataSource
StreamingDataSource->getContentType
StreamingDataSource->getLocator (locator = rtsp://127.0.0.1/sample_100kbit.avi)
javax.microedition.media.MediaException: Player cannot be created for video/avi
    at javax.microedition.media.Manager.createPlayer(), bci=135
 - com.iprs.test.Midlet.startApp(Midlet.java:14)
    at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
    at com.sun.midp.midlet.MIDletPeer.startApp(), bci=5
    at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=261
    at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=38
    at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=5
    at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=144
    at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
Midlet->destroyApp

This is the StartApp method -

    public void startApp() {
    try {
        System.out.println("Midlet->startApp");
        // create Player instance, realize it and then try to start it
        Player player = Manager.createPlayer(new StreamingDataSource("rtsp://127.0.0.1/sample_100kbit.avi")); //(new StreamingDataSource("rtsp://localhost:554/tuner1.wav")); //sample.mp3")); //sample_100kbit.mp4"));
            player.realize();
            player.start();
    } catch(Exception e) {
            e.printStackTrace();
    }
}

I have tried with some media types but i got the error. How it can be solved? Thanks, Eyal.

eyal
  • 2,379
  • 7
  • 40
  • 54

1 Answers1

2

The IP address 127.0.0.1 always points to the device you're using. So when used in a MIDlet, it points to the phone running the MIDlet. In other words, you're trying to stream a file from your phone to your phone.

This of course doesn't work since you don't have a running webserver on your phone.

To make it work you should figure out the correct IP address to your server.

If your phone is connected via WiFi you can most probably use a local IP such as 10.0.0.x or 192.168.0.x

If your phone is connected via GPRS or 3G, you'll need to figure out what IP your desktop computer has on the Internet, using a service such as www.whatismyip.com After that you have to make sure your server is accessible. In other words, make sure that your router is allowing traffic on the specific port used by the RTSP protocol, and guiding traffic on that port to your server.

To take it one step at a time, it might be a good idea to google for existing RTSP streams, and try those out first. That way you'll know that your JavaME code works fine.

As far as I remember, playing RTSP streams with JavaME (at least on newer phones) is fairly straight forward though. Should run with the standard Player, without any additional classes.

See this: J2ME/StreamingMedia.htm">http://www.java2s.com/Tutorial/Java/0430_J2ME/StreamingMedia.htm

You should also be able to test if a certain RTSP feed is working, simply by entering the URL into your phone browser. It should then launch the phone's default media player and play the stream.

mr_lou
  • 1,910
  • 2
  • 14
  • 26