From 933bbae77b1ee55cafc060840b85cc0074f46ca7 Mon Sep 17 00:00:00 2001 From: Kyle Bedell Date: Mon, 11 Mar 2019 19:55:36 -0700 Subject: [PATCH 1/2] Fix tvOS picture-in-picture compilation regression. --- ios/Video/RCTVideo.h | 4 +++- ios/Video/RCTVideo.m | 29 ++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ios/Video/RCTVideo.h b/ios/Video/RCTVideo.h index ad98db7ffa..dd8e6eadf1 100644 --- a/ios/Video/RCTVideo.h +++ b/ios/Video/RCTVideo.h @@ -14,7 +14,9 @@ @class RCTEventDispatcher; #if __has_include() -@interface RCTVideo : UIView +@interface RCTVideo : UIView +#elif TARGET_OS_TV +@interface RCTVideo : UIView #else @interface RCTVideo : UIView #endif diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index 3b6d4e96e9..c896e000cb 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -27,8 +27,6 @@ @implementation RCTVideo AVPlayer *_player; AVPlayerItem *_playerItem; NSDictionary *_source; - AVPictureInPictureController *_pipController; - void (^__strong _Nonnull _restoreUserInterfaceForPIPStopCompletionHandler)(BOOL); BOOL _playerItemObserversSet; BOOL _playerBufferEmpty; AVPlayerLayer *_playerLayer; @@ -79,6 +77,10 @@ @implementation RCTVideo #if __has_include() RCTVideoCache * _videoCache; #endif +#if TARGET_OS_IOS + void (^__strong _Nonnull _restoreUserInterfaceForPIPStopCompletionHandler)(BOOL); + AVPictureInPictureController *_pipController; +#endif } - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher @@ -103,9 +105,11 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher _playInBackground = false; _allowsExternalPlayback = YES; _playWhenInactive = false; - _pictureInPicture = false; + _pictureInPicture = false; _ignoreSilentSwitch = @"inherit"; // inherit, ignore, obey - _restoreUserInterfaceForPIPStopCompletionHandler = NULL; +#if TARGET_OS_IOS + _restoreUserInterfaceForPIPStopCompletionHandler = NULL; +#endif #if __has_include() _videoCache = [RCTVideoCache sharedInstance]; #endif @@ -793,6 +797,7 @@ - (void)setPlayWhenInactive:(BOOL)playWhenInactive - (void)setPictureInPicture:(BOOL)pictureInPicture { + #if TARGET_OS_IOS if (_pictureInPicture == pictureInPicture) { return; } @@ -807,8 +812,10 @@ - (void)setPictureInPicture:(BOOL)pictureInPicture [_pipController stopPictureInPicture]; }); } + #endif } +#if TARGET_OS_IOS - (void)setRestoreUserInterfaceForPIPStopCompletionHandler:(BOOL)restore { if (_restoreUserInterfaceForPIPStopCompletionHandler != NULL) { @@ -824,6 +831,7 @@ - (void)setupPipController { _pipController.delegate = self; } } +#endif - (void)setIgnoreSilentSwitch:(NSString *)ignoreSilentSwitch { @@ -1279,8 +1287,9 @@ - (void)usePlayerLayer [self.layer addSublayer:_playerLayer]; self.layer.needsDisplayOnBoundsChange = YES; - + #if TARGET_OS_IOS [self setupPipController]; + #endif } } @@ -1539,19 +1548,20 @@ - (NSString *)cacheDirectoryPath { #pragma mark - Picture in Picture +#if TARGET_OS_IOS - (void)pictureInPictureControllerDidStopPictureInPicture:(AVPictureInPictureController *)pictureInPictureController { if (self.onPictureInPictureStatusChanged) { self.onPictureInPictureStatusChanged(@{ - @"isActive": [NSNumber numberWithBool:false] - }); + @"isActive": [NSNumber numberWithBool:false] + }); } } - (void)pictureInPictureControllerDidStartPictureInPicture:(AVPictureInPictureController *)pictureInPictureController { if (self.onPictureInPictureStatusChanged) { self.onPictureInPictureStatusChanged(@{ - @"isActive": [NSNumber numberWithBool:true] - }); + @"isActive": [NSNumber numberWithBool:true] + }); } } @@ -1574,5 +1584,6 @@ - (void)pictureInPictureController:(AVPictureInPictureController *)pictureInPict } _restoreUserInterfaceForPIPStopCompletionHandler = completionHandler; } +#endif @end From 5dbf7e2b542475f043930e2dc784623be9fe160a Mon Sep 17 00:00:00 2001 From: Kyle Bedell Date: Tue, 12 Mar 2019 11:21:12 -0700 Subject: [PATCH 2/2] Remove unused delegate in header file. --- ios/Video/RCTVideo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Video/RCTVideo.h b/ios/Video/RCTVideo.h index dd8e6eadf1..19d5d19f96 100644 --- a/ios/Video/RCTVideo.h +++ b/ios/Video/RCTVideo.h @@ -14,7 +14,7 @@ @class RCTEventDispatcher; #if __has_include() -@interface RCTVideo : UIView +@interface RCTVideo : UIView #elif TARGET_OS_TV @interface RCTVideo : UIView #else