Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playback restricted on iOS for VEVO videos from YouTube API

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.

This video contains content from VEVO. It is restricted from playback on certain sites.

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.

What could I be doing wrong?

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.

like image 362
josephap Avatar asked Nov 06 '13 18:11

josephap


1 Answers

Using YouTube's YTPlayerView for iOS and setting the origin property to a valid URL allows many VEVO videos to be played properly.

In your View Controller:

@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];

With origin: origin

Without origin: no origin

like image 97
JAL Avatar answered Oct 31 '22 19:10

JAL