ios - 获取 YouTube 视频 URL - 数据 API 3.0

标签 ios url video youtube-api gdata

我一直在查看有关如何获取 channel 的 JSON 视频列表的 Google 文档。我想出了如何获取带有缩略图和标题等的视频列表......但我无法找到如何获取 VIDEO MP4(或任何其他格式)的 URL。

你看我需要在 iOS 应用程序中播放视频,我的应用程序需要实际的 VIDEO URL,而不是一些烦人的 url,它只返回缩略图或播放列表的列表......

我在网上找到了这些说明,它们与最后一部分不同:

You have to get the upload playlist id to get each videos uploaded. To get that, you need to get the channel id. After you have the playlist id from the channel id, it is pretty simple. I have written out the steps for all three below.

Also, we offer PubSubHubBub which allows you to be alerted every time a new video is added to a channel, or you could use SUP (V2) to see which resources have changed before making the calls.

Instructions to get video ids for all uploaded videos for a channel in V3

Get the channel id for the channel you want (you probably only need to do this once, then you can save it)

Use search.list Set type to channel Set q to the name of the channel you want Grab the channel id (something like this: "channelId": "UC0X2VuXXXXXXXXXXXXXXXX") Get the playlist id for the channel uploads using the channel id from step 1 (you probably only need to do this once, then you can save it)

Use channels.list Set id to UC0X2VuXXXXXXXXXXXXXXXX from step 2 Grab the uploads key from contentDetails (something like this: "uploads": "UU0XXXXXXXXXXXXXXXXXXXX") Get the videos via the playlistitems in the playlist using the playlist id from step 2

Use playlistItems.list Set playlistId to UU0XXXXXXXXXXXXXXXXXXXX from step 2 Go through each PlaylistItem and pull out the video id



如您所见,最后一部分说要通过播放列表项并提取视频 ID。我已经这样做了,但是我需要对视频 ID 做什么才能获取视频 URL ???

谁能帮我?

谢谢,丹。

最佳答案

      NSString *youtubeHTML = [[NSString alloc] initWithFormat:@"\
                             <html><head>\
                             <style type=\"text/css\">\
                             body {    background-color: transparent;\
                             color: white; \
                             }\
                             </style>\
                             </head><body style=\"margin:0\">\
                             <iframe class=\"youtube-player\" width=\"280\" height=\"210\" src=\"http://www.youtube.com/embed/%@?\" frameborder=\"0\" allowfullscreen=\"true\"></iframe>\
                             </body></html>", videoID];

您还可以使用 URL 显示/隐藏内容,hd,在特定时间开始。
youTubeView = [[UIWebView alloc] initWithFrame:CGRectMake(yourframe)];
[youTubeView loadHTMLString:youtubeHTML baseURL:nil];

关于ios - 获取 YouTube 视频 URL - 数据 API 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18824905/

相关文章:

video - 如何判断 youtube 视频的内​​容何时随 youtube API 发生变化?

ios - iOS 9 的 xcode 7.1 缺少 Objective C 领域静态框架所需的 libc++.dylib

iphone - SOAP 响应不完整

iphone - 为什么 Brightcove 播放器未在 UIWebview 中加载?

url - 多语言站点和 url 命名

c# - 如何在桌面应用程序和网站之间访问图像

android - 在 ffmpeg 监护人项目 (android) 中使用叠加视频过滤器

ipad - HTML5 视频不适用于 iPad 上的 jquery bxSlider 插件

android - FCM 在同时使用 iOS 和 Android 时处理问题

ios - 询问是否仍在播放由应用加载并启动的声音的iOS API方法