Using YTPlayerView to play embedded YouTube video in iOS failed with restriction error

前端 未结 4 1287
春和景丽
春和景丽 2020-12-19 03:27

I want play embedded YouTube video in iOS app using YTPlayerView provided at https://developers.google.com/youtube/v3/guides/ios_youtube_helper

When I tried to play

相关标签:
4条回答
  • 2020-12-19 03:53

    By setting the origin property in my playerVars I was able to play the embedded video.

    let playerVars = [
                         "playsinline" : 1,
                         "showinfo" : 0,
                         "rel" : 0,
                         "modestbranding" : 1,
                         "controls" : 1,
                         "origin" : "https://www.example.com"
                     ]
    

    Then call loadWithVideoId:: as you normally would.

    YouTube

    0 讨论(0)
  • 2020-12-19 04:00

    Swift 5.0

    @IBOutlet weak var videoPlayer: YTPlayerView!
    
     self.videoPlayer.load(withVideoId: "M7lc1UVf-VE", playerVars: ["origin": "http://www.youtube.com"])
    
    0 讨论(0)
  • 2020-12-19 04:01
    NSDictionary *playerVars = @{
                                 @"origin" : @"http://www.youtube.com",
                                 };
    [self.playerView loadWithVideoId:@"videoId" playerVars:playerVars];`
    

    This Objective-C version works for me.

    0 讨论(0)
  • 2020-12-19 04:06

    YTPlayerView inturn uses iframes to play youtube video. You cannot use iframe in playing copyrighted youtube videos you can use a uiwebView to play this as an alternative

    0 讨论(0)
提交回复
热议问题