swift - iOS app with YouTube v3 API and youtube-ios-player-helper can't autoplay videos -


i having problem autoplaying videos youtube-ios-player-helper pod provided google/youtube. here relevant part of app (ios 10, swift 3):

  • a channelvideosviewcontroller displays video thumbnails uiviews uitapgesturerecognizer in turn segues playerviewcontroller , passes videoid api call
  • a playerviewcontroller follows:

    var youtubeplayerview = ytplayerview() // player videos var youtubevideoid = string() // videoid api passed channelvideosviewcontroller  override func viewdidload() { // ... skipping ui stuff  view.addsubview(youtubeplayerview) youtubeplayerview.load(withvideoid: youtubevideoid, playervars: ["autoplay":1,"modestbranding":1,"showinfo":0,"rel":0]) } 

with code above helper library loads videos , plays them in fullscreen when press "big red button" want autoplay videos directly after segue view. there way this?

  • "autoplay":1 youtube docs doesn't seem cut ios.
  • youtubeplayerview.playvideo() doesn't anything

conform ytplayerviewdelegate protocol this:

self.youtubeplayer.delegate = self

now use delegate method play video automatically when player ready:

extension viewcontroller: ytplayerviewdelegate {     func playerviewdidbecomeready(_ playerview: ytplayerview) {         self.youtubeplayer.playvideo()     } } 

it works in case.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -