Search code examples
androidvideo-streaminghttp-live-streaminglive-streaminghttp-streaming

Android video live streaming


I am in big trouble, I could not play m3u8 file in my android videoview but it is so easy in iPhone. I googled and visited several forums and all are saying that it is not possible. But I tried vitamio(http://vov.io/vitamio/) and it can stream for 5 to 6 seconds. That is there is a chance to stream, but how ?

If the m3u8 streaming in android is hard, How can stream from an IPcamera to my android device?

If any one know about this, Please give a response, I am very thankful for your response because i spend much more time for this.


Solution

  • I had tried the devices having Android versions 2.1,2.2,2.3,2.3.6,and 4.0. The vitamio application can stream the url for 5 to 6 seconds in all devices except the device HTC onex having android version 4.0.

    My code for calling simple m3u8 url is given below.. Many thanks yorkw.

    Activity:

           package com.livestrean;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.MediaController;
    import android.widget.Toast;
    import android.widget.VideoView;
    
    public class streamplayer extends Activity {
        /** Called when the activity is first created. */
    
    
         private String path = "An m3u8 Url";
    
    
         private VideoView mVideoView;
    
    
    
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            try
            {
                setContentView(R.layout.surface_view_1);
                mVideoView = (VideoView) findViewById(R.id.surface_view);
    
                    mVideoView.setVideoURI(Uri.parse(path));                
                    mVideoView.setMediaController(new MediaController(this));
                    mVideoView.requestFocus();              
                    mVideoView.postInvalidateDelayed(100);        
                    mVideoView.start();
    
    
    
            }catch (Exception e) {
    
                Toast.makeText(streamplayer.this,"Error Occured:- " + e.getMessage(),Toast.LENGTH_SHORT).show();
            } 
        }
    }
    

    Layout:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <VideoView 
            android:id="@+id/surface_view" 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"/>
    
    </LinearLayout>
    

    Thanks