Hi,
I'm using AVPlayerViewController as a subview in a fullscreen UIViewController presented modally with UIModalTransitionStyleCrossDissolve.
As of tvOS 11, no controller input would work except for the menu button. Swipes were not recognized, button presses not recognziend, etc.
Adding a preferredFocusView fixes MOST of the control issues except Play/Pause is still not recognized.
- (UIView*)preferredFocusedView {
if (self.moviePlayerController != nil) {
return ((AVPlayerViewController*)self.moviePlayerController).view;
} else {
return self.view;
}
}
Additionally, after closing the video player, Play/Pause is no longer recognized anywhere in the application. Prior to presenting the AVPlayerViewController, the app receives Play/Pause button events just fine.
I've tried capturing the Play/Pause events via UITapGestureRecognizer and subclassing UIApplication to override the sendEvent method. Neither fire for Play/Pause once the AVPlayerViewController is loaded and app must be restarted.
- (void)sendEvent:(UIEvent*)event {
[super sendEvent:event];
if (self.remoteControlEventsDelegate) {
BOOL playPausePressed = NO;
if (event.subtype == UIEventSubtypeRemoteControlPlay || event.subtype == UIEventSubtypeRemoteControlPause || event.subtype == UIEventSubtypeRemoteControlTogglePlayPause) {
playPausePressed = YES;
}
else if ([event isKindOfClass:[UIPressesEvent class]]) {
for (UIPress *press in [(UIPressesEvent *)event allPresses]) {
BOOL buttonReleased = press.phase == UIPressPhaseEnded || press.phase == UIPressPhaseCancelled;
switch (press.type) {
case UIPressTypePlayPause:
playPausePressed = buttonReleased;
break;
default:
break;
}
}
}
if (playPausePressed && [self.remoteControlEventsDelegate respondsToSelector:@selector(playPausePressed)]) {
[self.remoteControlEventsDelegate playPausePressed];
}
}
}
This is a critical bug for video player apps.
How can we resolve this issue?
Thanks
James