ios - 将 Youtube 视频以高清格式嵌入 iOS 应用程序

标签 ios swift youtube uiwebview youtube-iframe-api

我尝试使用 YouTube 生成的 iframe 在 iOS 应用中嵌入 YouTube 视频,但无法以高清格式显示该视频。

我生成的 iframe 没有建议、播放器控件和最佳隐私。我尝试输入参数 vq=hd1080vq=large 但不起作用。

iframe的大小我应用的是与屏幕大小相同的:

webView.loadHTMLString("<html><body style=\"(margin:0)\"><embed width=\"\(view.frame.width)\" height=\"\(view.frame.height)\" src=\"https://www.youtube.com/embed/*********?rel=0&amp;showinfo=0\" frameborder=\"0\" allowfullscreen></embed></body></html>", baseURL: nil)

WebView 的大小是全屏。

最佳答案

您所看到的是移动设备上 iFrame API 的副产品。

根据关于 this issue 的讨论在 YouTube 的 iOS Helper Class 存储库(它只是为您在 UIWebView 中加载 iFrame 播放器,而不必手动设置所有内容)上,YouTube 不允许开发人员强制使用高质量视频以防止移动设备上的数据使用过多。

可以在以下问题中找到进一步的讨论(和解决方法):

Youtube iFrame API setPlaybackQuality ignored on mobile device

Loading Youtube iFrame API video at a lower quality

关于ios - 将 Youtube 视频以高清格式嵌入 iOS 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30264386/

相关文章:

ios - AVFoundation 在不同的视频上叠加文本,然后组合并导出

swift - 无法在 Swift 中访问多维数组

ios - Swift - 从选项卡栏 Controller 更新 View Controller 内的变量

Youtube 数据 API v3 : Sort by date not working

YouTube API 分析 - 所有 channel 视频的视频维度报告

ios - AVFoundation、AVCaptureMetadataOutput 截屏

ios - MvxBaseTouchViewPresenter : (ChoosePictureFromLibrary dialog does not appear)

android - 发布版本 apk 上的 400 错误请求

ios - 验证文本字段Swift 3

ios - 在 XCTest (UITesting) 中获取设备名称