Vladimir Kulyk Vladimir Kulyk - 1 month ago 106
Android Question

Android Java Youtube API v3.0 get video RTSP link

I want to play youtube video on

Surface
, using
MediaPlayer
.

So, I should put there direct video link.

Problem is: How to get this link on Android device?



Link like this: http://gdata.youtube.com/feeds/api/videos/VIDEO_ID

Is no longer available. Probably because of old and deprecated API v2.0.

But this web service somehow do the trick.

And result link works perfect. So it is still possible.

Answer

Try with this url

String ytInfoUrl="http://www.youtube.com/get_video_info?video_id=" + youtubeID + "&eurl="
                + URLEncoder.encode("https://youtube.googleapis.com/v/" + youtubeID, "UTF-8");

Open this using a HttpGet extract the RTSP urls from that info response.

edit

You can use this link for extracting the RTSP links https://github.com/flipstudio/YouTubeExtractor/blob/master/src/main/java/com/flipstudio/youtube/extractor/YouTubeExtractor.java