1

I want to implement video streaming in java me using rtsp url. When tested the code on devices, I get Media Exception stating Prefetch Error-33. Here's my code

    private void startStreaming()
    {
      try 
      {
        mplayer=Manager.createPlayer(videourl);

        mplayer.addPlayerListener(this);

        mplayer.realize();

        videoControl=(VideoControl) mplayer.getControl("VideoControl");

        if(videoControl!=null)
        {
            Item video=(Item) videoControl.initDisplayMode(videoControl.USE_GUI_PRIMITIVE, null);

            videoControl.setVisible(true);

            System.out.println("Playing");

            Form v=new Form("Playing Video");

            StringItem si=new StringItem("Status", "Playing....");

            v.append(video);

            display.setCurrent(v);
        }

        mplayer.prefetch();

        mplayer.start();
    } 

    catch(Exception noCanDo)
    {
        Form f=new Form("Error");

        f.append("Error : "+noCanDo);

        display.setCurrent(f);
    }
}

I have also tried using alternative method of using MIDlet.platformrequest(videourl) method which invokes default internal player of device to play video file. The player is being started but later on, a connection timeout prompt occurs. I have however tested the rtsp url and it works very much fine. Any suggestions as to how can I do video streaming using rtsp url in java me?

j0k
  • 22,600
  • 28
  • 79
  • 90
Chetan Khilare
  • 285
  • 1
  • 3
  • 14
  • use nokia developer forum wiki article for streaming RTSP in j2me it should work for nokia symbian belle sdk 1.1 and nokia sdk 2.0 http://www.developer.nokia.com/Community/Wiki/How_to_play_video_streaming_in_Java_ME – String Aug 27 '12 at 11:05

1 Answers1

0

Use this code for streamin RTSP,it should work for nokia symbian belle sdk 1.1 and nokia sdk 2.0

protected void startApp() throws MIDletStateChangeException {
        VideoCanvas VC = new VideoCanvas(this,url); 
        Display.getDisplay(this).setCurrent(VC); }

    }
    //videoCanvas Class

    public VideoCanvas(ExampleStreamingMIDlet midlet, String url) {
            this.midlet = midlet;
            this.url = url;
            addCommand(start);
            addCommand(stop);
            addCommand(back);
            addCommand(exit);
            setCommandListener(this);
            this.setFullScreenMode(true);
        }

    public void commandAction(Command c, Displayable arg1) {
            if(c == start) {
                start();
            }




    public void start() {
            try{

               Player player = Manager.createPlayer(url);
                player.addPlayerListener(this);
               player.realize();


                control = (VideoControl)player.getControl("VideoControl");
                if (control != null) {
                    control.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this);
                    control.setDisplaySize(176,144);
                    int width = control.getSourceWidth();
                    int height = control.getSourceHeight();
                    status2 = "Before: SW=" + width + "-SH=" + height + "-DW=" + control.getDisplayWidth() + "-DH=" + control.getDisplayHeight();
                }

                player.start();
            }
            catch(Exception e) {
                Alert erro = new Alert("Erro",e.getMessage(),null,AlertType.ERROR);
                Display.getDisplay(midlet).setCurrent(erro);
            }
        }

    public void stop() {
            if(player != null) {
                player.deallocate();
                player.close();
            }
        }
Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
String
  • 3,660
  • 10
  • 43
  • 66