Address some of the feedback from the pull reqeust
This commit is contained in:
committed by
Abdulrahman Alzenki
parent
4a16151195
commit
62dc913cb3
@@ -66,6 +66,7 @@ static int const RCTVideoUnset = -1;
|
||||
BOOL _playbackStalled;
|
||||
BOOL _playInBackground;
|
||||
BOOL _playWhenInactive;
|
||||
BOOL _pictureInPicture;
|
||||
NSString * _ignoreSilentSwitch;
|
||||
NSString * _resizeMode;
|
||||
BOOL _fullscreen;
|
||||
@@ -102,6 +103,7 @@ static int const RCTVideoUnset = -1;
|
||||
_playInBackground = false;
|
||||
_allowsExternalPlayback = YES;
|
||||
_playWhenInactive = false;
|
||||
_pictureInPicture = false;
|
||||
_ignoreSilentSwitch = @"inherit"; // inherit, ignore, obey
|
||||
_restoreUserInterfaceForPIPStopCompletionHandler = NULL;
|
||||
#if __has_include(<react-native-video/RCTVideoCache.h>)
|
||||
@@ -382,12 +384,6 @@ static int const RCTVideoUnset = -1;
|
||||
@"target": self.reactTag
|
||||
});
|
||||
}
|
||||
|
||||
if (@available(iOS 9, *)) {
|
||||
if (self.onIsPictureInPictureSupported) {
|
||||
self.onIsPictureInPictureSupported(@{@"supported": [NSNumber numberWithBool:(bool)[AVPictureInPictureController isPictureInPictureSupported]]});
|
||||
}
|
||||
}
|
||||
}];
|
||||
});
|
||||
_videoLoadStarted = YES;
|
||||
@@ -791,11 +787,16 @@ static int const RCTVideoUnset = -1;
|
||||
|
||||
- (void)setPictureInPicture:(BOOL)pictureInPicture
|
||||
{
|
||||
if (_pipController && pictureInPicture && ![_pipController isPictureInPictureActive]) {
|
||||
if (_pictureInPicture == pictureInPicture) {
|
||||
return;
|
||||
}
|
||||
|
||||
_pictureInPicture = pictureInPicture;
|
||||
if (_pipController && _pictureInPicture && ![_pipController isPictureInPictureActive]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[_pipController startPictureInPicture];
|
||||
});
|
||||
} else if (_pipController && !pictureInPicture && [_pipController isPictureInPictureActive]) {
|
||||
} else if (_pipController && !_pictureInPicture && [_pipController isPictureInPictureActive]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[_pipController stopPictureInPicture];
|
||||
});
|
||||
@@ -811,12 +812,10 @@ static int const RCTVideoUnset = -1;
|
||||
}
|
||||
|
||||
- (void)setupPipController {
|
||||
if (@available(iOS 9, *)) {
|
||||
if (!_pipController && _playerLayer && [AVPictureInPictureController isPictureInPictureSupported]) {
|
||||
// Create new controller passing reference to the AVPlayerLayer
|
||||
_pipController = [[AVPictureInPictureController alloc] initWithPlayerLayer:_playerLayer];
|
||||
_pipController.delegate = self;
|
||||
}
|
||||
if (!_pipController && _playerLayer && [AVPictureInPictureController isPictureInPictureSupported]) {
|
||||
// Create new controller passing reference to the AVPlayerLayer
|
||||
_pipController = [[AVPictureInPictureController alloc] initWithPlayerLayer:_playerLayer];
|
||||
_pipController.delegate = self;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1535,14 +1534,18 @@ static int const RCTVideoUnset = -1;
|
||||
#pragma mark - Picture in Picture
|
||||
|
||||
- (void)pictureInPictureControllerDidStopPictureInPicture:(AVPictureInPictureController *)pictureInPictureController {
|
||||
if (self.onIsPictureInPictureActive && _pipController) {
|
||||
self.onIsPictureInPictureActive(@{@"active": [NSNumber numberWithBool:false]});
|
||||
if (self.onPictureInPictureStatusChanged) {
|
||||
self.onPictureInPictureStatusChanged(@{
|
||||
@"isActive": [NSNumber numberWithBool:false]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pictureInPictureControllerDidStartPictureInPicture:(AVPictureInPictureController *)pictureInPictureController {
|
||||
if (self.onIsPictureInPictureActive && _pipController) {
|
||||
self.onIsPictureInPictureActive(@{@"active": [NSNumber numberWithBool:true]});
|
||||
if (self.onPictureInPictureStatusChanged) {
|
||||
self.onPictureInPictureStatusChanged(@{
|
||||
@"isActive": [NSNumber numberWithBool:true]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1560,6 +1563,9 @@ static int const RCTVideoUnset = -1;
|
||||
|
||||
- (void)pictureInPictureController:(AVPictureInPictureController *)pictureInPictureController restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:(void (^)(BOOL))completionHandler {
|
||||
NSAssert(_restoreUserInterfaceForPIPStopCompletionHandler == NULL, @"restoreUserInterfaceForPIPStopCompletionHandler was not called after picture in picture was exited.");
|
||||
if (self.onRestoreUserInterfaceForPictureInPictureStop) {
|
||||
self.onRestoreUserInterfaceForPictureInPictureStop(@{});
|
||||
}
|
||||
_restoreUserInterfaceForPIPStopCompletionHandler = completionHandler;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user