Loading RCTVideo.h +4 −1 Changes for RCTVideo.h: 4 added lines, 1 removed line. Original line number Diff line number Diff line #import "RCTView.h" #import <AVFoundation/AVFoundation.h> #import "AVKit/AVKit.h" #import "UIView+FindUIViewController.h" #import "RCTVideoPlayerViewController.h" #import "RCTVideoPlayerViewControllerDelegate.h" @class RCTEventDispatcher; @interface RCTVideo : UIView @interface RCTVideo : UIView <RCTVideoPlayerViewControllerDelegate> - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; Loading RCTVideo.m +74 −1 Changes for RCTVideo.m: 74 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; BOOL _paused; BOOL _repeat; NSString * _resizeMode; BOOL _fullscreenPlayerPresented; UIViewController * _presentingViewController; } - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher Loading Loading @@ -69,7 +71,9 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; } - (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem { AVPlayerViewController* playerLayer= [[AVPlayerViewController alloc] init]; RCTVideoPlayerViewController* playerLayer= [[RCTVideoPlayerViewController alloc] init]; playerLayer.showsPlaybackControls = NO; playerLayer.rctDelegate = self; playerLayer.view.frame = self.bounds; playerLayer.player = _player; playerLayer.view.frame = self.bounds; Loading Loading @@ -436,6 +440,54 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; _repeat = repeat; } - (BOOL)getFullscreen { return _fullscreenPlayerPresented; } - (void)setFullscreen:(BOOL)fullscreen { if( fullscreen && !_fullscreenPlayerPresented ) { // Ensure player view controller is not null if( !_playerViewController ) { [self usePlayerViewController]; } // Set presentation style to fullscreen [_playerViewController setModalPresentationStyle:UIModalPresentationFullScreen]; // 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; [_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 if ( !fullscreen && _fullscreenPlayerPresented ) { [self videoPlayerViewControllerWillDismiss:_playerViewController]; [_presentingViewController dismissViewControllerAnimated:true completion:^{ [self videoPlayerViewControllerDidDismiss:_playerViewController]; }]; } } - (void)usePlayerViewController { if( _player ) Loading Loading @@ -478,6 +530,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 applyModifiers]; [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidDismiss" body:@{@"target": self.reactTag}]; } } #pragma mark - React View Management - (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex Loading RCTVideo.xcodeproj/project.pbxproj +14 −0 Changes for RCTVideo.xcodeproj/project.pbxproj: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ objects = { /* 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 */ Loading @@ -25,6 +27,11 @@ /* 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 = "<group>"; }; 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+FindUIViewController.m"; sourceTree = "<group>"; }; 31CAFB2D1CADC77F009BCF6F /* RCTVideoPlayerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoPlayerViewController.h; sourceTree = "<group>"; }; 31CAFB2E1CADC77F009BCF6F /* RCTVideoPlayerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideoPlayerViewController.m; sourceTree = "<group>"; }; 31CAFB301CAE6B5F009BCF6F /* RCTVideoPlayerViewControllerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoPlayerViewControllerDelegate.h; sourceTree = "<group>"; }; BBD49E391AC8DEF000610F8E /* RCTVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideo.h; sourceTree = "<group>"; }; BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideo.m; sourceTree = "<group>"; }; BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoManager.h; sourceTree = "<group>"; }; Loading Loading @@ -55,8 +62,13 @@ children = ( BBD49E391AC8DEF000610F8E /* RCTVideo.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 = "<group>"; Loading Loading @@ -117,6 +129,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 31CAFB211CADA8CD009BCF6F /* UIView+FindUIViewController.m in Sources */, 31CAFB2F1CADC77F009BCF6F /* RCTVideoPlayerViewController.m in Sources */, BBD49E3F1AC8DEF000610F8E /* RCTVideo.m in Sources */, BBD49E401AC8DEF000610F8E /* RCTVideoManager.m in Sources */, ); Loading RCTVideoManager.m +6 −1 Changes for RCTVideoManager.m: 6 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -24,7 +24,11 @@ RCT_EXPORT_MODULE(); @"onVideoError", @"onVideoProgress", @"onVideoSeek", @"onVideoEnd" @"onVideoEnd", @"onVideoFullscreenPlayerWillPresent", @"onVideoFullscreenPlayerDidPresent", @"onVideoFullscreenPlayerWillDismiss", @"onVideoFullscreenPlayerDidDismiss" ]; } Loading @@ -43,6 +47,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 { Loading RCTVideoPlayerViewController.h 0 → 100644 +15 −0 Changes for RCTVideoPlayerViewController.h: 15 added lines, 0 removed lines. Original line number Diff line number Diff line // // RCTVideoPlayerViewController.h // RCTVideo // // Created by Stanisław Chmiela on 31.03.2016. // Copyright © 2016 Facebook. All rights reserved. // #import <AVKit/AVKit.h> #import "RCTVideo.h" #import "RCTVideoPlayerViewControllerDelegate.h" @interface RCTVideoPlayerViewController : AVPlayerViewController @property (nonatomic, weak) id<RCTVideoPlayerViewControllerDelegate> rctDelegate; @end Loading
RCTVideo.h +4 −1 Changes for RCTVideo.h: 4 added lines, 1 removed line. Original line number Diff line number Diff line #import "RCTView.h" #import <AVFoundation/AVFoundation.h> #import "AVKit/AVKit.h" #import "UIView+FindUIViewController.h" #import "RCTVideoPlayerViewController.h" #import "RCTVideoPlayerViewControllerDelegate.h" @class RCTEventDispatcher; @interface RCTVideo : UIView @interface RCTVideo : UIView <RCTVideoPlayerViewControllerDelegate> - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; Loading
RCTVideo.m +74 −1 Changes for RCTVideo.m: 74 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; BOOL _paused; BOOL _repeat; NSString * _resizeMode; BOOL _fullscreenPlayerPresented; UIViewController * _presentingViewController; } - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher Loading Loading @@ -69,7 +71,9 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; } - (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem { AVPlayerViewController* playerLayer= [[AVPlayerViewController alloc] init]; RCTVideoPlayerViewController* playerLayer= [[RCTVideoPlayerViewController alloc] init]; playerLayer.showsPlaybackControls = NO; playerLayer.rctDelegate = self; playerLayer.view.frame = self.bounds; playerLayer.player = _player; playerLayer.view.frame = self.bounds; Loading Loading @@ -436,6 +440,54 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; _repeat = repeat; } - (BOOL)getFullscreen { return _fullscreenPlayerPresented; } - (void)setFullscreen:(BOOL)fullscreen { if( fullscreen && !_fullscreenPlayerPresented ) { // Ensure player view controller is not null if( !_playerViewController ) { [self usePlayerViewController]; } // Set presentation style to fullscreen [_playerViewController setModalPresentationStyle:UIModalPresentationFullScreen]; // 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; [_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 if ( !fullscreen && _fullscreenPlayerPresented ) { [self videoPlayerViewControllerWillDismiss:_playerViewController]; [_presentingViewController dismissViewControllerAnimated:true completion:^{ [self videoPlayerViewControllerDidDismiss:_playerViewController]; }]; } } - (void)usePlayerViewController { if( _player ) Loading Loading @@ -478,6 +530,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 applyModifiers]; [_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidDismiss" body:@{@"target": self.reactTag}]; } } #pragma mark - React View Management - (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex Loading
RCTVideo.xcodeproj/project.pbxproj +14 −0 Changes for RCTVideo.xcodeproj/project.pbxproj: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ objects = { /* 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 */ Loading @@ -25,6 +27,11 @@ /* 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 = "<group>"; }; 31CAFB201CADA8CD009BCF6F /* UIView+FindUIViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+FindUIViewController.m"; sourceTree = "<group>"; }; 31CAFB2D1CADC77F009BCF6F /* RCTVideoPlayerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoPlayerViewController.h; sourceTree = "<group>"; }; 31CAFB2E1CADC77F009BCF6F /* RCTVideoPlayerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideoPlayerViewController.m; sourceTree = "<group>"; }; 31CAFB301CAE6B5F009BCF6F /* RCTVideoPlayerViewControllerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoPlayerViewControllerDelegate.h; sourceTree = "<group>"; }; BBD49E391AC8DEF000610F8E /* RCTVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideo.h; sourceTree = "<group>"; }; BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideo.m; sourceTree = "<group>"; }; BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoManager.h; sourceTree = "<group>"; }; Loading Loading @@ -55,8 +62,13 @@ children = ( BBD49E391AC8DEF000610F8E /* RCTVideo.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 = "<group>"; Loading Loading @@ -117,6 +129,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 31CAFB211CADA8CD009BCF6F /* UIView+FindUIViewController.m in Sources */, 31CAFB2F1CADC77F009BCF6F /* RCTVideoPlayerViewController.m in Sources */, BBD49E3F1AC8DEF000610F8E /* RCTVideo.m in Sources */, BBD49E401AC8DEF000610F8E /* RCTVideoManager.m in Sources */, ); Loading
RCTVideoManager.m +6 −1 Changes for RCTVideoManager.m: 6 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -24,7 +24,11 @@ RCT_EXPORT_MODULE(); @"onVideoError", @"onVideoProgress", @"onVideoSeek", @"onVideoEnd" @"onVideoEnd", @"onVideoFullscreenPlayerWillPresent", @"onVideoFullscreenPlayerDidPresent", @"onVideoFullscreenPlayerWillDismiss", @"onVideoFullscreenPlayerDidDismiss" ]; } Loading @@ -43,6 +47,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 { Loading
RCTVideoPlayerViewController.h 0 → 100644 +15 −0 Changes for RCTVideoPlayerViewController.h: 15 added lines, 0 removed lines. Original line number Diff line number Diff line // // RCTVideoPlayerViewController.h // RCTVideo // // Created by Stanisław Chmiela on 31.03.2016. // Copyright © 2016 Facebook. All rights reserved. // #import <AVKit/AVKit.h> #import "RCTVideo.h" #import "RCTVideoPlayerViewControllerDelegate.h" @interface RCTVideoPlayerViewController : AVPlayerViewController @property (nonatomic, weak) id<RCTVideoPlayerViewControllerDelegate> rctDelegate; @end