RagHaven
RagHaven

Reputation: 4327

Video Streaming in Android

I am working on an application that tries to display the video which is streaming on a webserver. I have the HTTP link for the video stream. To connect to the webserver I am connecting to a specific WIFI which enables me to access the video.

I have taken care of the WIFI connectivity. I am having a problem when I try to display the video on my app using VideoView. I used a tool which showed me that I was receiving data from the server. So my application is receiving the packets of data for the video but it is unable to display it.

The code is like this :

    private VideoView videoView;
    videoView = (VideoView)findViewById(R.id.VideoView_videoOnly);
    ....
    ....
    //connect to the router
    String ip = "http://192.168.2.250";
    URL url = null;
    try {
        url = new URL(ip);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    URLConnection connection = null;
    try {
        connection = url.openConnection();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    String vidLink = "http://XXXX:[email protected]/axis-cgi/mjpg/video.cgi";
    //set up video streaming
    MediaController mc = new MediaController(this);
    mc.setAnchorView(videoView);
    mc.setMediaPlayer(videoView);
    Uri video = Uri.parse(vidLink);
    videoView.setMediaController(mc);
    videoView.setVideoURI(video);
    videoView.start();

}

}

XXXX:XXXX is the username and password to access the video stream

Upvotes: 0

Views: 1824

Answers (1)

Alexander
Alexander

Reputation: 48232

According to the URL you are using, one can guess, you are receiving the stream in the MJPEG format. MJPEG is not natively supported by Android. You will have to break your stream into jpegs, then create a Bitmap from each jpeg, then display bitmaps one by one.

Upvotes: 1

Related Questions