I'm having trouble with the Youtube youtube-ios-player-helper library. I can load a video into the player and it plays but if I tap pause the video stops for a few seconds and then starts playing again.
The incredibly simple UIViewController code to start the video is:
- (void)viewDidLoad {
[super viewDidLoad];
self.player = [[YTPlayerView alloc] initWithFrame:CGRectMake(X, Y, WIDTH, HEIGHT)];
self.player.delegate = self;
[self.view addSubview:self.player];
[self.player loadWithVideoId:@"bQCjOm4p5jM"];
}
I instrumented the didChangeToState delegate method with NSLog as follows:
- (void)playerView:(YTPlayerView *)playerView didChangeToState:(YTPlayerState)state {
switch (state) {
case kYTPlayerStatePlaying:
NSLog(@"Started playback");
break;
case kYTPlayerStatePaused:
NSLog(@"Paused playback");
break;
default:
NSLog(@"didChangeToState %d", state);
break;
}
}
In the Xcode log, when I tap 'play' to start the video playing, I see:
didChangeToState 4
The value 4 does not appear to be defined in YTPlayerView.m
. When the video actually starts playing I see the expected Started playback
log message.
When I tap 'pause', I don't see anything in the log (no didChangeToState
event triggered - the event I'd expect would be kYTPlayerStatePaused
per the YTPlayerView docs). However a few seconds later, the video starts playing again, and then I see two consecutive Started playback
log messages (kYTPlayerStatePlaying
events). Every time I press 'pause' to try to pause the video, it pauses for a few seconds (with no kYTPlayerStatePaused
event), but then it starts playing again and I see Started playback
log messages.
Anyone else seeing this? Anyone know where to go from here? This is Xcode 6.2 and build target is iOS 8.0.