How to use the iOS app to play my limited videos

We have a YouTube account from which we are trying to play content, but playback in our iOS app using the YouTube helper is limited: https://developers.google.com/youtube/v3/guides/ios_youtube_helper#best_practices

iOS playback error

Perhaps this is due to the anonymity of the web view created by the helper?

Can I set up an assistant or account differently to unblock content? I guess I could serve the web view from the whitelisted host, basically bypassing / rewriting the YouTube helper, but that wouldn't be ideal - an extra HTTP request, etc.

Thank you in advance

+3


source to share


3 answers


Here is my current understanding and work around.

Problem

Any limitation on access to the channel (whitelisting / blacklisting, etc.) requires the parent iframe to be served from the real host. The iOS YouTube Support Library manually creates a webview that loads the iframe and therefore the channel is blocked from playing because it is not possible to restrict playback in the parent (anonymous webview).

It's easy to test this for a given channel by embedding the channel video embed in a simple local HTML page and loading it into your browser. Playback will be blocked.

Decision

So, we need a web page that uses the iFrame API, served by a host that is not blacklisted or whitelisted (depending on your channel access control). I took the HTML template from the youtube helper library and parameterized the url to populate the parameters to initialize the template:

new YT.Player('player', %@);

      

So, instead of loading data from the HTML template string in the helper, I now load the request:



[self.webView loadRequest:req];

      

The end result is that the "handleHttpNavigationToUrl" condition in the next block was causing Safari to open on page load, so it's better to comment out or handle:

- (BOOL)webView:(UIWebView *)webView
    shouldStartLoadWithRequest:(NSURLRequest *)request
                navigationType:(UIWebViewNavigationType)navigationType {
  if ([request.URL.scheme isEqual:@"ytplayer"]) {
    [self notifyDelegateOfYouTubeCallbackUrl:request.URL];
    return NO;
  } else if ([request.URL.scheme isEqual: @"http"] || [request.URL.scheme isEqual:@"https"]) {
    return [self handleHttpNavigationToUrl:request.URL];
  }
  return YES;
}

      

New problem

This work adds another delay to the video download stream for the user. A new HTTP request to serve the start page combines the existing steps:

  • Download iFrame API YouTube JS
  • Loading the iFrame Player
  • Start video stream initialized to player

All of this, not just initializing the main player with the stream url. Not a great user experience.

I plan to work on this by preloading the page, API and iframe ready to initialize with a video id as requested by the user.

+3


source


The problem with mines was that when I pressed the play button it showed me an error. I tried to download youtube video.

This video contains content from <.. channelname ..>. It is limited to playback on certain sites. Watch on YouTube.

The solution I used was

NSDictionary *playerVars = @{
    @"origin" : @"http://www.youtube.com",
    ...any other variables
};
[self.playerView loadWithVideoId:videoId playerVars:playerVars];

      



just add the origin variable to playerVar and you are good to go.

Hope this helps someone.

thank

+1


source


Yes you are right. The helper library is basically a wrapper around the iFrame API. You can repurpose the helper or use the iFrame API right on your white node.

0


source







All Articles