I want to play Youtube Video on VideoView . I have searched very much & find that VideoView Support rtsp URL Video . But I am getting error: My android device is 2.3.5
By using this way i play rtsp video in android.
videourl="rtsp://..........";
videoView = (VideoView) findViewById(R.id.video_View);
progressDialog = ProgressDialog.show(Video.this, "",
"Buffering video...", true);
progressDialog.setCancelable(false);
// progressDialog.dismiss();
MediaController mediaController = new MediaController(Video.this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(videourl);// insert video url
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.requestFocus();
sync = new myAsync();
sync.execute();
// PlayVideo();
}
private class myAsync extends AsyncTask {
int duration = 0;
//int current = 0;
@Override
protected Void doInBackground(Void... params) {
videoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
videoView.seekTo(check);
videoView.start();
duration = videoView.getDuration();
}
});
do {
current = videoView.getCurrentPosition();
System.out.println("duration - " + duration + " current- "
+ current);
/*if(current/600==0)
{
//sync.cancel(true);
videoView.pause();
try {
wait(300000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();q
}
videoView.resume();
videoView.seekTo(current);
}*/
}
if (sync.isCancelled())
break;
} while (current != duration || current == 0);
return null;
}
}