From 9be76e3674b2c30853065d8d6bc075b64b4661c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 20:34:08 +0200 Subject: [PATCH 01/20] Add view controller finding functions We need them to be able to present another view controller --- RCTVideo.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/RCTVideo.m b/RCTVideo.m index 3c0fa291..7bd52933 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -524,6 +524,26 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; } } +#pragma mark - View Controller retrieval + +// http://stackoverflow.com/questions/1340434/get-to-uiviewcontroller-from-uiview/2596519 + +- (UIViewController *) firstAvailableUIViewController { + // convenience function for casting and to "mask" the recursive function + return (UIViewController *)[self traverseResponderChainForUIViewController]; +} + +- (id) traverseResponderChainForUIViewController { + id nextResponder = [self nextResponder]; + if ([nextResponder isKindOfClass:[UIViewController class]]) { + return nextResponder; + } else if ([nextResponder isKindOfClass:[UIView class]]) { + return [nextResponder traverseResponderChainForUIViewController]; + } else { + return nil; + } +} + #pragma mark - Lifecycle - (void)removeFromSuperview From 5244a5b797f4b4d4c1b84b6144f995854560c256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 20:34:22 +0200 Subject: [PATCH 02/20] Add _fullscreen property to the view --- RCTVideo.m | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/RCTVideo.m b/RCTVideo.m index 7bd52933..268c4dab 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -37,6 +37,8 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; BOOL _paused; BOOL _repeat; NSString * _resizeMode; + BOOL _fullScreenPlayerPresented; + UIViewController * _presentingViewController; } - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher @@ -425,6 +427,54 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; _repeat = repeat; } +- (BOOL)getFullscreen +{ + return _fullScreenPlayerPresented; +} + +- (void)setFullscreen:(BOOL)fullscreen +{ + if( fullscreen ) + { + // Ensure player view controller is not null + if( !_playerViewController ) + { + [self usePlayerViewController]; + } + // Set presentation style to fullscreen + [_playerViewController setModalPresentationStyle:UIModalPresentationOverFullScreen]; + + // Find the nearest view controller + UIViewController *viewController = [self firstAvailableUIViewController]; + if( !viewController ) + { + UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; + viewController = keyWindow.rootViewController; + if( viewController.childViewControllers.count > 0 ) + { + viewController = viewController.childViewControllers.lastObject; + } + } + if( viewController ) + { + _presentingViewController = viewController; + [viewController presentViewController:_playerViewController animated:true completion:^{ + _playerViewController.showsPlaybackControls = YES; + _fullScreenPlayerPresented = fullscreen; + }]; + + } + } + else + { + [_presentingViewController dismissViewControllerAnimated:true completion:^{ + _fullScreenPlayerPresented = fullscreen; + _presentingViewController = nil; + }]; + } +} + + - (void)usePlayerViewController { if( _player ) From 8ebfa6e4dbacaf5f901d78b2a239712302fe90e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 20:36:39 +0200 Subject: [PATCH 03/20] Export property from Objective-C to React --- RCTVideoManager.m | 1 + Video.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/RCTVideoManager.m b/RCTVideoManager.m index 7c0dfbc2..bcbd3f3e 100644 --- a/RCTVideoManager.m +++ b/RCTVideoManager.m @@ -43,6 +43,7 @@ RCT_EXPORT_VIEW_PROPERTY(volume, float); RCT_EXPORT_VIEW_PROPERTY(rate, float); RCT_EXPORT_VIEW_PROPERTY(seek, float); RCT_EXPORT_VIEW_PROPERTY(currentTime, float); +RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL); - (NSDictionary *)constantsToExport { diff --git a/Video.js b/Video.js index cc763c37..b429bbfd 100644 --- a/Video.js +++ b/Video.js @@ -21,6 +21,7 @@ export default class Video extends Component { constructor(props, context) { super(props, context); this.seek = this.seek.bind(this); + this.goFullscreen = this.goFullscreen.bind(this); this._assignRoot = this._assignRoot.bind(this); this._onLoadStart = this._onLoadStart.bind(this); this._onLoad = this._onLoad.bind(this); @@ -38,6 +39,10 @@ export default class Video extends Component { this.setNativeProps({ seek: time }); } + goFullscreen() { + this.setNativeProps({ fullscreen: true }); + } + _assignRoot(component) { this._root = component; } @@ -134,6 +139,7 @@ Video.propTypes = { /* Native only */ src: PropTypes.object, seek: PropTypes.number, + fullscreen: PropTypes.bool, /* Wrapper component */ source: PropTypes.object, From 6ab72c4cb82529807d52a02a1eefcd131034e6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 20:51:22 +0200 Subject: [PATCH 04/20] Move View Controller retrieval to external UIView category --- RCTVideo.m | 20 -------------------- RCTVideo.xcodeproj/project.pbxproj | 6 ++++++ UIView+FindUIViewController.h | 15 +++++++++++++++ UIView+FindUIViewController.m | 28 ++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 UIView+FindUIViewController.h create mode 100644 UIView+FindUIViewController.m diff --git a/RCTVideo.m b/RCTVideo.m index 268c4dab..277b8247 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -574,26 +574,6 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; } } -#pragma mark - View Controller retrieval - -// http://stackoverflow.com/questions/1340434/get-to-uiviewcontroller-from-uiview/2596519 - -- (UIViewController *) firstAvailableUIViewController { - // convenience function for casting and to "mask" the recursive function - return (UIViewController *)[self traverseResponderChainForUIViewController]; -} - -- (id) traverseResponderChainForUIViewController { - id nextResponder = [self nextResponder]; - if ([nextResponder isKindOfClass:[UIViewController class]]) { - return nextResponder; - } else if ([nextResponder isKindOfClass:[UIView class]]) { - return [nextResponder traverseResponderChainForUIViewController]; - } else { - return nil; - } -} - #pragma mark - Lifecycle - (void)removeFromSuperview diff --git a/RCTVideo.xcodeproj/project.pbxproj b/RCTVideo.xcodeproj/project.pbxproj index 9a65aa45..a8d2cddf 100644 --- a/RCTVideo.xcodeproj/project.pbxproj +++ b/RCTVideo.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 31CAFB211CADA8CD009BCF6F /* UIView+FindUIViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */; }; BBD49E3F1AC8DEF000610F8E /* RCTVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */; }; BBD49E401AC8DEF000610F8E /* RCTVideoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3C1AC8DEF000610F8E /* RCTVideoManager.m */; }; /* End PBXBuildFile section */ @@ -25,6 +26,8 @@ /* Begin PBXFileReference section */ 134814201AA4EA6300B7C361 /* libRCTVideo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVideo.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 31CAFB1F1CADA8CD009BCF6F /* UIView+FindUIViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+FindUIViewController.h"; sourceTree = ""; }; + 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+FindUIViewController.m"; sourceTree = ""; }; BBD49E391AC8DEF000610F8E /* RCTVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideo.h; sourceTree = ""; }; BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideo.m; sourceTree = ""; }; BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoManager.h; sourceTree = ""; }; @@ -53,6 +56,8 @@ 58B511D21A9E6C8500147676 = { isa = PBXGroup; children = ( + 31CAFB1F1CADA8CD009BCF6F /* UIView+FindUIViewController.h */, + 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */, BBD49E391AC8DEF000610F8E /* RCTVideo.h */, BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */, BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */, @@ -117,6 +122,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 31CAFB211CADA8CD009BCF6F /* UIView+FindUIViewController.m in Sources */, BBD49E3F1AC8DEF000610F8E /* RCTVideo.m in Sources */, BBD49E401AC8DEF000610F8E /* RCTVideoManager.m in Sources */, ); diff --git a/UIView+FindUIViewController.h b/UIView+FindUIViewController.h new file mode 100644 index 00000000..09214261 --- /dev/null +++ b/UIView+FindUIViewController.h @@ -0,0 +1,15 @@ +// +// UIView+FindUIViewController.h +// RCTVideo +// +// Created by Stanisław Chmiela on 31.03.2016. +// Copyright © 2016 Facebook. All rights reserved. +// +// Source: http://stackoverflow.com/a/3732812/1123156 + +#import + +@interface UIView (FindUIViewController) +- (UIViewController *) firstAvailableUIViewController; +- (id) traverseResponderChainForUIViewController; +@end diff --git a/UIView+FindUIViewController.m b/UIView+FindUIViewController.m new file mode 100644 index 00000000..bc721b96 --- /dev/null +++ b/UIView+FindUIViewController.m @@ -0,0 +1,28 @@ +// +// UIView+FindUIViewController.m +// RCTVideo +// +// Created by Stanisław Chmiela on 31.03.2016. +// Copyright © 2016 Facebook. All rights reserved. +// +// Source: http://stackoverflow.com/a/3732812/1123156 + +#import "UIView+FindUIViewController.h" + +@implementation UIView (FindUIViewController) +- (UIViewController *) firstAvailableUIViewController { + // convenience function for casting and to "mask" the recursive function + return (UIViewController *)[self traverseResponderChainForUIViewController]; +} + +- (id) traverseResponderChainForUIViewController { + id nextResponder = [self nextResponder]; + if ([nextResponder isKindOfClass:[UIViewController class]]) { + return nextResponder; + } else if ([nextResponder isKindOfClass:[UIView class]]) { + return [nextResponder traverseResponderChainForUIViewController]; + } else { + return nil; + } +} +@end From 412d187b33e701ced1b66b4d65dbedb74a8eb672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 20:59:25 +0200 Subject: [PATCH 05/20] Update package.json to copy new files --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 3e15b8b1..d0b6d8e7 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,8 @@ "RCTVideoManager.h", "RCTVideoManager.m", "README.md", + "UIView+FindUIViewController.h", + "UIView+FindUIViewController.m", "Video.js", "VideoResizeMode.js", "react-native-video.podspec" From 2ef7c3024e3c4735795ed7f6dae98fce7a58583f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 21:03:54 +0200 Subject: [PATCH 06/20] Include new category to RCTVideo --- RCTVideo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/RCTVideo.h b/RCTVideo.h index 757ed542..077f2e0a 100644 --- a/RCTVideo.h +++ b/RCTVideo.h @@ -1,6 +1,7 @@ #import "RCTView.h" #import #import "AVKit/AVKit.h" +#import "UIView+FindUIViewController.h" @class RCTEventDispatcher; From 6d05b7bf79c2ae2aeef5286e88d4f58ac0e9f28f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 21:35:10 +0200 Subject: [PATCH 07/20] Add option for listening to fullscreen player events --- RCTVideo.m | 5 ++++- RCTVideoManager.m | 6 +++++- Video.js | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/RCTVideo.m b/RCTVideo.m index 277b8247..4c001076 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -458,18 +458,21 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; if( viewController ) { _presentingViewController = viewController; + [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerWillPresent" body:@{@"target": self.reactTag}]; [viewController presentViewController:_playerViewController animated:true completion:^{ _playerViewController.showsPlaybackControls = YES; _fullScreenPlayerPresented = fullscreen; + [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidPresent" body:@{@"target": self.reactTag}]; }]; - } } else { + [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerWillDismiss" body:@{@"target": self.reactTag}]; [_presentingViewController dismissViewControllerAnimated:true completion:^{ _fullScreenPlayerPresented = fullscreen; _presentingViewController = nil; + [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidDismiss" body:@{@"target": self.reactTag}]; }]; } } diff --git a/RCTVideoManager.m b/RCTVideoManager.m index bcbd3f3e..b75e379c 100644 --- a/RCTVideoManager.m +++ b/RCTVideoManager.m @@ -24,7 +24,11 @@ RCT_EXPORT_MODULE(); @"onVideoError", @"onVideoProgress", @"onVideoSeek", - @"onVideoEnd" + @"onVideoEnd", + @"onVideoFullscreenPlayerWillPresent", + @"onVideoFullscreenPlayerDidPresent", + @"onVideoFullscreenPlayerWillDismiss", + @"onVideoFullscreenPlayerDidDismiss" ]; } diff --git a/Video.js b/Video.js index b429bbfd..a986d944 100644 --- a/Video.js +++ b/Video.js @@ -29,6 +29,10 @@ export default class Video extends Component { this._onProgress = this._onProgress.bind(this); this._onSeek = this._onSeek.bind(this); this._onEnd = this._onEnd.bind(this); + this._onFullscreenPlayerWillPresent = this._onFullscreenPlayerWillPresent.bind(this); + this._onFullscreenPlayerDidPresent = this._onFullscreenPlayerDidPresent.bind(this); + this._onFullscreenPlayerWillDismiss = this._onFullscreenPlayerWillDismiss.bind(this); + this._onFullscreenPlayerDidDismiss = this._onFullscreenPlayerDidDismiss.bind(this); } setNativeProps(nativeProps) { @@ -83,6 +87,30 @@ export default class Video extends Component { } } + _onFullscreenPlayerWillPresent(event) { + if (this.props.onFullscreenPlayerWillPresent) { + this.props.onFullscreenPlayerWillPresent(event.nativeEvent); + } + } + + _onFullscreenPlayerDidPresent(event) { + if (this.props.onFullscreenPlayerWillPresent) { + this.props.onFullscreenPlayerDidPresent(event.nativeEvent); + } + } + + _onFullscreenPlayerWillDismiss(event) { + if (this.props.onFullscreenPlayerWillPresent) { + this.props.onFullscreenPlayerWillDismiss(event.nativeEvent); + } + } + + _onFullscreenPlayerDidDismiss(event) { + if (this.props.onFullscreenPlayerDidDismiss) { + this.props.onFullscreenPlayerDidDismiss(event.nativeEvent); + } + } + render() { const { source, @@ -124,6 +152,10 @@ export default class Video extends Component { onVideoProgress: this._onProgress, onVideoSeek: this._onSeek, onVideoEnd: this._onEnd, + onVideoFullscreenPlayerWillPresent: this._onFullscreenPlayerWillPresent, + onVideoFullscreenPlayerDidPresent: this._onFullscreenPlayerDidPresent, + onVideoFullscreenPlayerWillDismiss: this._onFullscreenPlayerWillDismiss, + onVideoFullscreenPlayerDidDismiss: this._onFullscreenPlayerDidDismiss, }); return ( @@ -157,6 +189,10 @@ Video.propTypes = { onProgress: PropTypes.func, onSeek: PropTypes.func, onEnd: PropTypes.func, + onFullscreenPlayerWillPresent: PropTypes.func, + onFullscreenPlayerDidPresent: PropTypes.func, + onFullscreenPlayerWillDismiss: PropTypes.func, + onFullscreenPlayerDidDismiss: PropTypes.func, /* Required by react-native */ scaleX: React.PropTypes.number, From 4bbce5e3787fd593c3badd8810c5696dab5bd9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 21:40:49 +0200 Subject: [PATCH 08/20] Fix wrong conditions --- Video.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Video.js b/Video.js index a986d944..2d40a955 100644 --- a/Video.js +++ b/Video.js @@ -94,13 +94,13 @@ export default class Video extends Component { } _onFullscreenPlayerDidPresent(event) { - if (this.props.onFullscreenPlayerWillPresent) { + if (this.props.onFullscreenPlayerDidPresent) { this.props.onFullscreenPlayerDidPresent(event.nativeEvent); } } _onFullscreenPlayerWillDismiss(event) { - if (this.props.onFullscreenPlayerWillPresent) { + if (this.props.onFullscreenPlayerWillDismiss) { this.props.onFullscreenPlayerWillDismiss(event.nativeEvent); } } From d073847ce021077358ca6d48ecb0877b8caabacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 23:10:25 +0200 Subject: [PATCH 09/20] Fix dismissal code not running by creating subclass of view controller and notifying view --- RCTVideo.h | 2 ++ RCTVideo.m | 4 +++- RCTVideo.xcodeproj/project.pbxproj | 6 ++++++ RCTVideoPlayerViewController.h | 14 ++++++++++++++ RCTVideoPlayerViewController.m | 22 ++++++++++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 RCTVideoPlayerViewController.h create mode 100644 RCTVideoPlayerViewController.m diff --git a/RCTVideo.h b/RCTVideo.h index 077f2e0a..ba43d89c 100644 --- a/RCTVideo.h +++ b/RCTVideo.h @@ -2,6 +2,7 @@ #import #import "AVKit/AVKit.h" #import "UIView+FindUIViewController.h" +#import "RCTVideoPlayerViewController.h" @class RCTEventDispatcher; @@ -10,5 +11,6 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; - (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem; +- (void)setFullscreen:(BOOL)fullscreen; @end diff --git a/RCTVideo.m b/RCTVideo.m index 4c001076..a32778a8 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -71,7 +71,8 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; } - (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem { - AVPlayerViewController* playerLayer= [[AVPlayerViewController alloc] init]; + RCTVideoPlayerViewController* playerLayer= [[RCTVideoPlayerViewController alloc] init]; + playerLayer.rctDelegate = self; playerLayer.view.frame = self.bounds; playerLayer.player = _player; playerLayer.view.frame = self.bounds; @@ -472,6 +473,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; [_presentingViewController dismissViewControllerAnimated:true completion:^{ _fullScreenPlayerPresented = fullscreen; _presentingViewController = nil; + [self setControls:_controls]; [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidDismiss" body:@{@"target": self.reactTag}]; }]; } diff --git a/RCTVideo.xcodeproj/project.pbxproj b/RCTVideo.xcodeproj/project.pbxproj index a8d2cddf..eabedd86 100644 --- a/RCTVideo.xcodeproj/project.pbxproj +++ b/RCTVideo.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 31CAFB211CADA8CD009BCF6F /* UIView+FindUIViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */; }; + 31CAFB2F1CADC77F009BCF6F /* RCTVideoPlayerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 31CAFB2E1CADC77F009BCF6F /* RCTVideoPlayerViewController.m */; }; BBD49E3F1AC8DEF000610F8E /* RCTVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */; }; BBD49E401AC8DEF000610F8E /* RCTVideoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3C1AC8DEF000610F8E /* RCTVideoManager.m */; }; /* End PBXBuildFile section */ @@ -28,6 +29,8 @@ 134814201AA4EA6300B7C361 /* libRCTVideo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVideo.a; sourceTree = BUILT_PRODUCTS_DIR; }; 31CAFB1F1CADA8CD009BCF6F /* UIView+FindUIViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+FindUIViewController.h"; sourceTree = ""; }; 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+FindUIViewController.m"; sourceTree = ""; }; + 31CAFB2D1CADC77F009BCF6F /* RCTVideoPlayerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoPlayerViewController.h; sourceTree = ""; }; + 31CAFB2E1CADC77F009BCF6F /* RCTVideoPlayerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideoPlayerViewController.m; sourceTree = ""; }; BBD49E391AC8DEF000610F8E /* RCTVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideo.h; sourceTree = ""; }; BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideo.m; sourceTree = ""; }; BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoManager.h; sourceTree = ""; }; @@ -60,6 +63,8 @@ 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */, BBD49E391AC8DEF000610F8E /* RCTVideo.h */, BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */, + 31CAFB2D1CADC77F009BCF6F /* RCTVideoPlayerViewController.h */, + 31CAFB2E1CADC77F009BCF6F /* RCTVideoPlayerViewController.m */, BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */, BBD49E3C1AC8DEF000610F8E /* RCTVideoManager.m */, 134814211AA4EA7D00B7C361 /* Products */, @@ -123,6 +128,7 @@ buildActionMask = 2147483647; files = ( 31CAFB211CADA8CD009BCF6F /* UIView+FindUIViewController.m in Sources */, + 31CAFB2F1CADC77F009BCF6F /* RCTVideoPlayerViewController.m in Sources */, BBD49E3F1AC8DEF000610F8E /* RCTVideo.m in Sources */, BBD49E401AC8DEF000610F8E /* RCTVideoManager.m in Sources */, ); diff --git a/RCTVideoPlayerViewController.h b/RCTVideoPlayerViewController.h new file mode 100644 index 00000000..aac5e026 --- /dev/null +++ b/RCTVideoPlayerViewController.h @@ -0,0 +1,14 @@ +// +// RCTVideoPlayerViewController.h +// RCTVideo +// +// Created by Stanisław Chmiela on 31.03.2016. +// Copyright © 2016 Facebook. All rights reserved. +// + +#import +#import "RCTVideo.h" + +@interface RCTVideoPlayerViewController : AVPlayerViewController +@property (nonatomic, weak) id rctVideoView; +@end diff --git a/RCTVideoPlayerViewController.m b/RCTVideoPlayerViewController.m new file mode 100644 index 00000000..118180a7 --- /dev/null +++ b/RCTVideoPlayerViewController.m @@ -0,0 +1,22 @@ +// +// RCTVideoPlayerViewController.m +// RCTVideo +// +// Created by Stanisław Chmiela on 31.03.2016. +// Copyright © 2016 Facebook. All rights reserved. +// + +#import "RCTVideoPlayerViewController.h" + +@interface RCTVideoPlayerViewController () + +@end + +@implementation RCTVideoPlayerViewController + +- (IBAction)close:(id)sender +{ + [self.rctVideoView setFullscreen:false]; +} + +@end From 79fac2b2a9845f34c9a49ff159e06227071e9e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 23:12:43 +0200 Subject: [PATCH 10/20] Add new files to the package --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index d0b6d8e7..716870fe 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "README.md", "UIView+FindUIViewController.h", "UIView+FindUIViewController.m", + "RCTVideoPlayerViewController.h", + "RCTVideoPlayerViewController.m", "Video.js", "VideoResizeMode.js", "react-native-video.podspec" From c3b5a1b4cf8cf430ae7215c0afb00e104e588872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 10:51:02 +0200 Subject: [PATCH 11/20] Add new RCTVideoPlayerViewControllerDelegate protocol --- RCTVideo.xcodeproj/project.pbxproj | 2 ++ RCTVideoPlayerViewControllerDelegate.h | 15 +++++++++++++++ package.json | 1 + 3 files changed, 18 insertions(+) create mode 100644 RCTVideoPlayerViewControllerDelegate.h diff --git a/RCTVideo.xcodeproj/project.pbxproj b/RCTVideo.xcodeproj/project.pbxproj index eabedd86..6fc58565 100644 --- a/RCTVideo.xcodeproj/project.pbxproj +++ b/RCTVideo.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+FindUIViewController.m"; sourceTree = ""; }; 31CAFB2D1CADC77F009BCF6F /* RCTVideoPlayerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoPlayerViewController.h; sourceTree = ""; }; 31CAFB2E1CADC77F009BCF6F /* RCTVideoPlayerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideoPlayerViewController.m; sourceTree = ""; }; + 31CAFB301CAE6B5F009BCF6F /* RCTVideoPlayerViewControllerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoPlayerViewControllerDelegate.h; sourceTree = ""; }; BBD49E391AC8DEF000610F8E /* RCTVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideo.h; sourceTree = ""; }; BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideo.m; sourceTree = ""; }; BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoManager.h; sourceTree = ""; }; @@ -62,6 +63,7 @@ 31CAFB1F1CADA8CD009BCF6F /* UIView+FindUIViewController.h */, 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */, BBD49E391AC8DEF000610F8E /* RCTVideo.h */, + 31CAFB301CAE6B5F009BCF6F /* RCTVideoPlayerViewControllerDelegate.h */, BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */, 31CAFB2D1CADC77F009BCF6F /* RCTVideoPlayerViewController.h */, 31CAFB2E1CADC77F009BCF6F /* RCTVideoPlayerViewController.m */, diff --git a/RCTVideoPlayerViewControllerDelegate.h b/RCTVideoPlayerViewControllerDelegate.h new file mode 100644 index 00000000..ec6500af --- /dev/null +++ b/RCTVideoPlayerViewControllerDelegate.h @@ -0,0 +1,15 @@ +// +// RCTVideoPlayerViewControllerDelegate.h +// RCTVideo +// +// Created by Stanisław Chmiela on 01.04.2016. +// Copyright © 2016 Facebook. All rights reserved. +// + +#import +#import "AVKit/AVKit.h" + +@protocol RCTVideoPlayerViewControllerDelegate +- (void)videoPlayerViewControllerWillDismiss:(AVPlayerViewController *)playerViewController; +- (void)videoPlayerViewControllerDidDismiss:(AVPlayerViewController *)playerViewController; +@end diff --git a/package.json b/package.json index 716870fe..c37bbeae 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "UIView+FindUIViewController.m", "RCTVideoPlayerViewController.h", "RCTVideoPlayerViewController.m", + "RCTVideoPlayerViewControllerDelegate.h", "Video.js", "VideoResizeMode.js", "react-native-video.podspec" From 9fefa996f284338a9efe4237016f571b080073dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 10:51:31 +0200 Subject: [PATCH 12/20] Use the delegate in controller --- RCTVideoPlayerViewController.h | 3 ++- RCTVideoPlayerViewController.m | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/RCTVideoPlayerViewController.h b/RCTVideoPlayerViewController.h index aac5e026..fc2675fc 100644 --- a/RCTVideoPlayerViewController.h +++ b/RCTVideoPlayerViewController.h @@ -8,7 +8,8 @@ #import #import "RCTVideo.h" +#import "RCTVideoPlayerViewControllerDelegate.h" @interface RCTVideoPlayerViewController : AVPlayerViewController -@property (nonatomic, weak) id rctVideoView; +@property (nonatomic, weak) id rctDelegate; @end diff --git a/RCTVideoPlayerViewController.m b/RCTVideoPlayerViewController.m index 118180a7..b1b768d7 100644 --- a/RCTVideoPlayerViewController.m +++ b/RCTVideoPlayerViewController.m @@ -14,9 +14,15 @@ @implementation RCTVideoPlayerViewController -- (IBAction)close:(id)sender +- (void)viewDidDisappear:(BOOL)animated { - [self.rctVideoView setFullscreen:false]; + [super viewDidDisappear:animated]; + [_rctDelegate videoPlayerViewControllerDidDismiss:self]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [_rctDelegate videoPlayerViewControllerWillDismiss:self]; + [super viewWillDisappear:animated]; } @end From 931ea75eddfff82e7050b6f38242f2dd744a1411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 10:52:05 +0200 Subject: [PATCH 13/20] Implement delegate in RCTVideo --- RCTVideo.h | 4 ++-- RCTVideo.m | 29 +++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/RCTVideo.h b/RCTVideo.h index ba43d89c..6f8aeab2 100644 --- a/RCTVideo.h +++ b/RCTVideo.h @@ -3,14 +3,14 @@ #import "AVKit/AVKit.h" #import "UIView+FindUIViewController.h" #import "RCTVideoPlayerViewController.h" +#import "RCTVideoPlayerViewControllerDelegate.h" @class RCTEventDispatcher; -@interface RCTVideo : UIView +@interface RCTVideo : UIView - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; - (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem; -- (void)setFullscreen:(BOOL)fullscreen; @end diff --git a/RCTVideo.m b/RCTVideo.m index a32778a8..a57f67d9 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -469,17 +469,13 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; } else { - [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerWillDismiss" body:@{@"target": self.reactTag}]; + [self videoPlayerViewControllerWillDismiss:_playerViewController]; [_presentingViewController dismissViewControllerAnimated:true completion:^{ - _fullScreenPlayerPresented = fullscreen; - _presentingViewController = nil; - [self setControls:_controls]; - [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidDismiss" body:@{@"target": self.reactTag}]; + [self videoPlayerViewControllerDidDismiss:_playerViewController]; }]; } } - - (void)usePlayerViewController { if( _player ) @@ -522,6 +518,27 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; } } +#pragma mark - RCTVideoPlayerViewControllerDelegate + +- (void)videoPlayerViewControllerWillDismiss:(AVPlayerViewController *)playerViewController +{ + if (_playerViewController == playerViewController && _fullScreenPlayerPresented) + { + [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerWillDismiss" body:@{@"target": self.reactTag}]; + } +} + +- (void)videoPlayerViewControllerDidDismiss:(AVPlayerViewController *)playerViewController +{ + if (_playerViewController == playerViewController && _fullScreenPlayerPresented) + { + _fullScreenPlayerPresented = false; + _presentingViewController = nil; + [self setControls:_controls]; + [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidDismiss" body:@{@"target": self.reactTag}]; + } +} + #pragma mark - React View Management - (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex From f6ee6a91a3dab23eea4d1a3e60843d50929966c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 11:12:50 +0200 Subject: [PATCH 14/20] Use API instead of prop to show and hide fullscreen player --- Video.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Video.js b/Video.js index 2d40a955..60859b17 100644 --- a/Video.js +++ b/Video.js @@ -21,7 +21,8 @@ export default class Video extends Component { constructor(props, context) { super(props, context); this.seek = this.seek.bind(this); - this.goFullscreen = this.goFullscreen.bind(this); + this.presentFullscreenPlayer = this.presentFullscreenPlayer.bind(this); + this.dismissFullscreenPlayer = this.dismissFullscreenPlayer.bind(this); this._assignRoot = this._assignRoot.bind(this); this._onLoadStart = this._onLoadStart.bind(this); this._onLoad = this._onLoad.bind(this); @@ -43,10 +44,14 @@ export default class Video extends Component { this.setNativeProps({ seek: time }); } - goFullscreen() { + presentFullscreenPlayer() { this.setNativeProps({ fullscreen: true }); } + dismissFullscreenPlayer() { + this.setNativeProps({ fullscreen: false }); + } + _assignRoot(component) { this._root = component; } @@ -207,5 +212,6 @@ const RCTVideo = requireNativeComponent('RCTVideo', Video, { nativeOnly: { src: true, seek: true, + fullscreen: true, }, }); From c39898be96e18d4f7df7faa9809e778f7d0e5dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 11:13:01 +0200 Subject: [PATCH 15/20] Minor fixes --- RCTVideo.xcodeproj/project.pbxproj | 6 +++--- RCTVideoPlayerViewController.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/RCTVideo.xcodeproj/project.pbxproj b/RCTVideo.xcodeproj/project.pbxproj index 6fc58565..502dd2a2 100644 --- a/RCTVideo.xcodeproj/project.pbxproj +++ b/RCTVideo.xcodeproj/project.pbxproj @@ -60,15 +60,15 @@ 58B511D21A9E6C8500147676 = { isa = PBXGroup; children = ( - 31CAFB1F1CADA8CD009BCF6F /* UIView+FindUIViewController.h */, - 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */, BBD49E391AC8DEF000610F8E /* RCTVideo.h */, - 31CAFB301CAE6B5F009BCF6F /* RCTVideoPlayerViewControllerDelegate.h */, BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */, + 31CAFB301CAE6B5F009BCF6F /* RCTVideoPlayerViewControllerDelegate.h */, 31CAFB2D1CADC77F009BCF6F /* RCTVideoPlayerViewController.h */, 31CAFB2E1CADC77F009BCF6F /* RCTVideoPlayerViewController.m */, BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */, BBD49E3C1AC8DEF000610F8E /* RCTVideoManager.m */, + 31CAFB1F1CADA8CD009BCF6F /* UIView+FindUIViewController.h */, + 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */, 134814211AA4EA7D00B7C361 /* Products */, ); sourceTree = ""; diff --git a/RCTVideoPlayerViewController.h b/RCTVideoPlayerViewController.h index fc2675fc..d427b63d 100644 --- a/RCTVideoPlayerViewController.h +++ b/RCTVideoPlayerViewController.h @@ -11,5 +11,5 @@ #import "RCTVideoPlayerViewControllerDelegate.h" @interface RCTVideoPlayerViewController : AVPlayerViewController -@property (nonatomic, weak) id rctDelegate; +@property (nonatomic, weak) id rctDelegate; @end From b030a5587b6e4fd2db5dbd1d75737191eaa2333b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 12:34:52 +0200 Subject: [PATCH 16/20] Fix controller not rotating --- RCTVideo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RCTVideo.m b/RCTVideo.m index a57f67d9..f8d920f9 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -443,7 +443,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; [self usePlayerViewController]; } // Set presentation style to fullscreen - [_playerViewController setModalPresentationStyle:UIModalPresentationOverFullScreen]; + [_playerViewController setModalPresentationStyle:UIModalPresentationFullScreen]; // Find the nearest view controller UIViewController *viewController = [self firstAvailableUIViewController]; From 3b3761dc8118d6936732240a034d56b361620396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 12:52:23 +0200 Subject: [PATCH 17/20] Apply modifiers after fullscreen player dismissal --- RCTVideo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RCTVideo.m b/RCTVideo.m index f8d920f9..4284f24d 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -534,7 +534,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; { _fullScreenPlayerPresented = false; _presentingViewController = nil; - [self setControls:_controls]; + [self applyModifiers]; [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidDismiss" body:@{@"target": self.reactTag}]; } } From 9635a0d76bdc2a0955c5e19daeec1394f3afad71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 13:04:16 +0200 Subject: [PATCH 18/20] Do not trigger unsatisfiable constraints alert when possible --- RCTVideo.m | 1 + 1 file changed, 1 insertion(+) diff --git a/RCTVideo.m b/RCTVideo.m index 4284f24d..56e962df 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -72,6 +72,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; - (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem { RCTVideoPlayerViewController* playerLayer= [[RCTVideoPlayerViewController alloc] init]; + playerLayer.showsPlaybackControls = NO; playerLayer.rctDelegate = self; playerLayer.view.frame = self.bounds; playerLayer.player = _player; From 4120a2a3b29bd88ce84d18f623f93a11ca4af165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 14:55:23 +0200 Subject: [PATCH 19/20] Rename variable fullScreen to fullscreen --- RCTVideo.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RCTVideo.m b/RCTVideo.m index 56e962df..dc2ba34f 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -37,7 +37,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; BOOL _paused; BOOL _repeat; NSString * _resizeMode; - BOOL _fullScreenPlayerPresented; + BOOL _fullscreenPlayerPresented; UIViewController * _presentingViewController; } @@ -431,7 +431,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; - (BOOL)getFullscreen { - return _fullScreenPlayerPresented; + return _fullscreenPlayerPresented; } - (void)setFullscreen:(BOOL)fullscreen @@ -463,7 +463,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerWillPresent" body:@{@"target": self.reactTag}]; [viewController presentViewController:_playerViewController animated:true completion:^{ _playerViewController.showsPlaybackControls = YES; - _fullScreenPlayerPresented = fullscreen; + _fullscreenPlayerPresented = fullscreen; [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidPresent" body:@{@"target": self.reactTag}]; }]; } @@ -523,7 +523,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; - (void)videoPlayerViewControllerWillDismiss:(AVPlayerViewController *)playerViewController { - if (_playerViewController == playerViewController && _fullScreenPlayerPresented) + if (_playerViewController == playerViewController && _fullscreenPlayerPresented) { [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerWillDismiss" body:@{@"target": self.reactTag}]; } @@ -531,9 +531,9 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; - (void)videoPlayerViewControllerDidDismiss:(AVPlayerViewController *)playerViewController { - if (_playerViewController == playerViewController && _fullScreenPlayerPresented) + if (_playerViewController == playerViewController && _fullscreenPlayerPresented) { - _fullScreenPlayerPresented = false; + _fullscreenPlayerPresented = false; _presentingViewController = nil; [self applyModifiers]; [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidDismiss" body:@{@"target": self.reactTag}]; From d304bfecbead7cc7bac84d560cb3b04f6ed77ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 1 Apr 2016 14:56:03 +0200 Subject: [PATCH 20/20] Fix possibility of trying to open multiple fullscreen video players --- RCTVideo.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RCTVideo.m b/RCTVideo.m index dc2ba34f..25cf2b9d 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -436,7 +436,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; - (void)setFullscreen:(BOOL)fullscreen { - if( fullscreen ) + if( fullscreen && !_fullscreenPlayerPresented ) { // Ensure player view controller is not null if( !_playerViewController ) @@ -468,7 +468,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; }]; } } - else + else if ( !fullscreen && _fullscreenPlayerPresented ) { [self videoPlayerViewControllerWillDismiss:_playerViewController]; [_presentingViewController dismissViewControllerAnimated:true completion:^{