Media player using YouTube?

I am developing an example application using MediaPlayer . Using the source folder, you can play the video. But I want to play through the URL . How can I achieve this?

My code is:

 VideoView videoView = (VideoView) findViewById(R.id.VideoView); MediaController mediaController = new MediaController(this); mediaController.setAnchorView(videoView); // Set video link (mp4 format ) Uri video = Uri.parse("http://www.youtube.com/watch?v=T1Wgp3mLa_E"); videoView.setMediaController(mediaController); videoView.setVideoURI(video); videoView.start(); 
+7
source share
3 answers

You need to get the correct URL (rtsp), not the link to the player page you are using. You can get it programmatically using google data api

Once you do, you just replace

"http://www.youtube.com/watch?v=T1Wgp3mLa_E" with "rtsp: //v8.cache1.c.youtube.com/CiILENy73wIaGQnxa4t5p6BVTxMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"

in your existing code, and it should work.

Note. Video quality while streaming on your own video image can be very poor compared to how it looks when played on a YouTube site or in a player application.

+4
source

Do you have rtsp links from gdata api: gdata api with this: http://gdata.youtube.com/feeds/api/videos?&max-results=20&v=2&format=1&q="+ URLEncoder.encode(activity.criteria)

 Element rsp = (Element)entry.getElementsByTagName("media:content").item(1); String anotherurl=rsp.getAttribute("url"); 

In gdata api we get only this type of links: rtsp://v3.cache7.c.youtube.com/CiILENy73wIaGQlOCTh0GvUeYRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp

They play in the VideoView.

My answer link: RTSP links

+2
source

To get quality videos, I checked what these guys did. It really helped me!

I am posting a link so you can check your project and use your code .

+1
source

All Articles