0
votes

Im wondering how to play youtube video directly in webview the same as on desktop browser.

    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"UserAgent": @"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.5.3 (KHTML, like Gecko) Version/8.0.5 Safari/600.5.3" }];
    [self.view addSubview:aWebView];
    [aWebView loadRequest:requestObj];

But it's still forcing webview to switch playing video in this iphone video player ? i guess ML..PLayer... ?It's dosent matter, i want play video in webview, And it's can be youtube frame, must be directly youtube.com/watch/video

1

1 Answers

0
votes

I think you will find so many thread with same question. Use URL like

https://www.youtube.com/embed/videoId

Where videoId is unique for each video.

Other approach, refer

https://developers.google.com/youtube/v3/guides/ios_youtube_helper#adding_ytplayerview