安卓 Java Youtube API v3.0 获取视频RTSP链接 [英] Android Java Youtube API v3.0 get video RTSP link

查看:31
本文介绍了安卓 Java Youtube API v3.0 获取视频RTSP链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Surface 上播放 youtube 视频,使用 MediaPlayer.
所以,我应该把直接的视频链接放在那里.
问题是:如何在 Android 设备上获取此链接?

链接如下:http://gdata.youtube.com/feeds/api/videos/VIDEO_ID
不再被提供.可能是因为旧的和已弃用的 API v2.0.
但是这个网络服务以某种方式解决了这个问题.
结果链接完美无缺.所以还是有可能的.

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.

推荐答案

试试这个网址

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

使用 HttpGet 打开它,从该信息响应中提取 RTSP 网址.

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

编辑

您可以使用此链接提取 RTSP 链接https://github.com/flipstudio/YouTubeExtractor/blob/master/src/main/java/com/flipstudio/youtube/extractor/YouTubeExtractor.java

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

编辑

很多已经改变,请使用这个项目进行正确的提取 https://github.com/HaarigerHarald/android-youtubeExtractor/blob/master/youtubeExtractor/src/main/java/at/huber/youtubeExtractor/YouTubeExtractor.java

A lot have been changed please use this project for proper extraction https://github.com/HaarigerHarald/android-youtubeExtractor/blob/master/youtubeExtractor/src/main/java/at/huber/youtubeExtractor/YouTubeExtractor.java

这篇关于安卓 Java Youtube API v3.0 获取视频RTSP链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆