Header Ads

How to stream a video to play from a specific time in android?

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/playvideo" 
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent"
        android:keepScreenOn="true" 
        android:layout_centerInParent="true"></VideoView> 



</RelativeLayout>
Android:
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.videolayout);
        this.videoView=(VideoView)findViewById(R.id.playvideo);


         play();

    }
     private void play(){
            MediaController mediaController = new MediaController(this);
            mediaController.setAnchorView(this.videoView);  

         Uri video=Uri.parse("http://your.mp4/35.mp4");
            Log.e("Uri video",video.toString());
            videoView.setMediaController(mediaController);
            videoView.setVideoURI(video);     
            videoView.seekTo(60000*10);//10 mins...
            videoView.start();
            videoView.setOnCompletionListener(new OnCompletionListener(){

                public void onCompletion(MediaPlayer arg0) {
                    // TODO Auto-generated method stub

                }

            });
     }

No comments:

Powered by Blogger.