I was trying to play youtube videos from my application, and had a hard time to do that. First, of all youtube videos wouldn’t play in your android emulator, so you need to test your application in a android device.
To do that, you have to set your application to Debuggable mode that you can do at:
AndroidManifest.xml -> Application -> Set Debuggable to true
You might also need to install specific drivers for the device you wish to test on.
Next, to play youtube videos you should get the rtsp(Real Time Streaming Protocol) link for your video which you can get from m.youtube.com, then do:
VideoView video=(VideoView) findViewById(R.id.videoView1); MediaController mediaController = new MediaController(this); mediaController.setAnchorView(video); video.setMediaController(mediaController); video.setKeepScreenOn(true); video.setVideoURI(Uri.parse(video_url)); //where video_url is the rtsp location of youtube video video.requestFocus(); video.start();
I will discuss about how you can stretch the video to full screen.