I have embedded YouTube in my application using YTPlayerView helper library for iOS the main issue I am facing right now is that I have embedded the multiple instances of YTPlayerView within scrollview and its loosing its not calling the changestate
playback properly. The problem occurs when two videos are loaded concurrently.
Asked
Active
Viewed 448 times
-2

JAL
- 41,701
- 23
- 172
- 300

Faisal Javaid
- 129
- 1
- 8
1 Answers
0
you can not use multiple instance of ytplayer in same view as it described in this link see here
- The library does not support concurrent video playback in multiple YTPlayerView instances. If your application has multiple YTPlayerView instances, a recommended best practice is to pause or stop playback in any existing instances before starting playback in a different instance. In the example application that ships with the project, the ViewControllers make use of NSNotificationCenter to dispatch notifications that playback is about to begin. Other ViewControllers are notified and will pause playback in their YTPlayerView instances.

Pratik Jamariya
- 810
- 1
- 10
- 35
-
I am doing the same thing you have mentioned to handle the playback but and also handling the delegate but still the problem is there – Faisal Javaid Feb 16 '16 at 10:37
-
are you using two ytplayer in the same view?if so you cant use 2 ytplayers i tested by myself if you have 2 ytplayers in same view then you have to pause or stop one of them and play or resume another one.... – Pratik Jamariya Feb 16 '16 at 10:59
-
if you want to achieve multiple ytplayer you can nest uiviewcontroller and handle individual ytplayers you can use this method to nest viewcontroller addChildViewController: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/addChildViewController: – Pratik Jamariya Feb 16 '16 at 11:08
-
no thats not what I am doing ,I am actually nesting the controller – Faisal Javaid Feb 16 '16 at 11:16
-
are you handling ytplayers in individual child controllers?that should work – Pratik Jamariya Feb 16 '16 at 11:20
-
well i tried to use multiple ytplayer adding chiled VC but not working well i can suggest you a way but it may lead to hard code. You can have an another uiwebview and play using iframe on html. you may implement your logic as your requirements. Refer to this link https://www.developerfeed.com/how-embed-youtube-video-uiview-iphone/. Yeah using uiwebview youtube videos may not load in simulater but works perfect in device hope this helps – Pratik Jamariya Feb 16 '16 at 12:51
-
another solution is you can use MPMoviePlayerController – Pratik Jamariya Feb 16 '16 at 12:57