iOS上的播放受限于来自YouTube API的VEVO视频 [英] Playback restricted on iOS for VEVO videos from YouTube API
问题描述
我已根据建议使用UIWebView将视频(从YouTube API v3中提取)嵌入到我的iPhone应用中。问题是某些视频(例如来自VEVO的视频)在尝试在设备上播放时会产生以下错误。
I have embedded videos (pulled from YouTube API v3) into my iPhone app using a UIWebView as suggested. The problem is that some videos, such as those from VEVO, produce the following error when attempting to play them on the device.
此视频包含来自VEVO的内容。限制在某些网站上播放。
This video contains content from VEVO. It is restricted from playback on certain sites.
这不应该发生,因为像Flipboard和Rockpack这样的应用似乎也是如此使用UIWebView,能够播放来自VEVO和其他来源的视频。
This should not occur, since apps like Flipboard and Rockpack also seem to be using a UIWebView, and are able to play videos from VEVO and other sources.
我可能做错了什么?
PS:我知道有其他帖子以某种方式触及这个问题,但是他们无法解决这个具体问题。
PS: I am aware that there exist other posts that touch upon this issue in some way, but they fail to address this specific problem.
推荐答案
使用YouTube的 YTPlayerView for iOS和将 origin
属性设置为有效的URL可以正常播放许多VEVO视频。
Using YouTube's YTPlayerView for iOS and setting the origin
property to a valid URL allows many VEVO videos to be played properly.
在视图控制器中:
@property (weak, nonatomic) IBOutlet YTPlayerView *playerView;
// ..
NSDictionary *playerVars = @{
@"playsinline" : @1,
@"showinfo" : @0,
@"rel" : @0,
@"controls" : @1,
@"origin" : @"https://www.example.com", // this is critical
@"modestbranding" : @1
};
[self.playerView loadWithVideoId:@"Ri7-vnrJD3k" playerVars:playerVars];
来源
:
< img src =https://i.stack.imgur.com/LTtnj.pngalt =origin>
With origin
:
没有来源
:
这篇关于iOS上的播放受限于来自YouTube API的VEVO视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!