问题描述
我想在 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链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!