2015-03-30 23:07:55 -06:00
|
|
|
#import "RCTVideoManager.h"
|
|
|
|
#import "RCTVideo.h"
|
2017-01-11 05:43:43 -07:00
|
|
|
#import <React/RCTBridge.h>
|
2018-10-26 07:21:41 -06:00
|
|
|
#import <React/RCTUIManager.h>
|
2015-04-04 18:55:37 -06:00
|
|
|
#import <AVFoundation/AVFoundation.h>
|
2015-03-30 23:07:55 -06:00
|
|
|
|
|
|
|
@implementation RCTVideoManager
|
|
|
|
|
2015-04-09 13:29:11 -06:00
|
|
|
RCT_EXPORT_MODULE();
|
|
|
|
|
2015-03-30 23:07:55 -06:00
|
|
|
- (UIView *)view
|
|
|
|
{
|
2015-04-06 13:17:32 -06:00
|
|
|
return [[RCTVideo alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
|
|
|
}
|
|
|
|
|
2015-07-10 17:03:17 -06:00
|
|
|
- (dispatch_queue_t)methodQueue
|
|
|
|
{
|
2018-10-26 07:21:41 -06:00
|
|
|
return self.bridge.uiManager.methodQueue;
|
2015-07-10 17:03:17 -06:00
|
|
|
}
|
|
|
|
|
2015-04-08 00:49:14 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(src, NSDictionary);
|
2018-11-26 15:50:31 -07:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(maxBitRate, float);
|
2015-04-04 18:55:37 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString);
|
2015-03-31 00:29:15 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL);
|
2018-06-05 19:40:12 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(allowsExternalPlayback, BOOL);
|
2018-06-21 10:08:37 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(textTracks, NSArray);
|
2018-06-02 03:24:13 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(selectedTextTrack, NSDictionary);
|
2018-07-17 15:14:21 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(selectedAudioTrack, NSDictionary);
|
2015-04-07 21:38:16 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(paused, BOOL);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(muted, BOOL);
|
2015-12-22 16:39:04 -07:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(controls, BOOL);
|
2015-04-07 21:38:16 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(volume, float);
|
2015-10-30 03:34:54 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(playInBackground, BOOL);
|
2016-04-29 06:16:21 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(playWhenInactive, BOOL);
|
2017-04-20 12:10:06 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(ignoreSilentSwitch, NSString);
|
2015-04-07 21:38:16 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(rate, float);
|
2018-06-20 23:09:45 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(seek, NSDictionary);
|
2015-12-22 16:39:04 -07:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(currentTime, float);
|
2016-03-31 12:36:39 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL);
|
2018-10-18 16:21:46 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(fullscreenAutorotate, BOOL);
|
2018-10-07 21:24:50 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(fullscreenOrientation, NSString);
|
2018-10-25 07:56:20 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(filter, NSString);
|
2018-12-13 20:30:38 -07:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(filterEnabled, BOOL);
|
2016-10-01 12:23:50 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(progressUpdateInterval, float);
|
2016-12-12 17:16:11 -07:00
|
|
|
/* Should support: onLoadStart, onLoad, and onError to stay consistent with Image */
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoLoadStart, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoLoad, RCTBubblingEventBlock);
|
2017-01-11 05:51:45 -07:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoBuffer, RCTBubblingEventBlock);
|
2016-12-12 17:16:11 -07:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoError, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoProgress, RCTBubblingEventBlock);
|
2018-09-19 06:28:49 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onBandwidthUpdate, RCTBubblingEventBlock);
|
2016-12-12 17:16:11 -07:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoSeek, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoEnd, RCTBubblingEventBlock);
|
2017-02-13 19:38:02 -07:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onTimedMetadata, RCTBubblingEventBlock);
|
2018-07-12 22:48:58 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoAudioBecomingNoisy, RCTBubblingEventBlock);
|
2016-12-12 17:16:11 -07:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoFullscreenPlayerWillPresent, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoFullscreenPlayerDidPresent, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoFullscreenPlayerWillDismiss, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoFullscreenPlayerDidDismiss, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onReadyForDisplay, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onPlaybackStalled, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onPlaybackResume, RCTBubblingEventBlock);
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onPlaybackRateChange, RCTBubblingEventBlock);
|
2018-10-07 16:59:10 -06:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onVideoExternalPlaybackChange, RCTBubblingEventBlock);
|
2018-10-26 07:21:41 -06:00
|
|
|
RCT_REMAP_METHOD(save,
|
|
|
|
options:(NSDictionary *)options
|
|
|
|
reactTag:(nonnull NSNumber *)reactTag
|
|
|
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
|
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
|
|
{
|
|
|
|
[self.bridge.uiManager prependUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTVideo *> *viewRegistry) {
|
|
|
|
RCTVideo *view = viewRegistry[reactTag];
|
|
|
|
if (![view isKindOfClass:[RCTVideo class]]) {
|
|
|
|
RCTLogError(@"Invalid view returned from registry, expecting RCTVideo, got: %@", view);
|
|
|
|
} else {
|
|
|
|
[view save:options resolve:resolve reject:reject];
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
2015-03-30 23:07:55 -06:00
|
|
|
|
|
|
|
- (NSDictionary *)constantsToExport
|
|
|
|
{
|
2015-05-10 17:01:25 -06:00
|
|
|
return @{
|
|
|
|
@"ScaleNone": AVLayerVideoGravityResizeAspect,
|
|
|
|
@"ScaleToFill": AVLayerVideoGravityResize,
|
|
|
|
@"ScaleAspectFit": AVLayerVideoGravityResizeAspect,
|
|
|
|
@"ScaleAspectFill": AVLayerVideoGravityResizeAspectFill
|
|
|
|
};
|
2015-03-30 23:07:55 -06:00
|
|
|
}
|
|
|
|
|
2017-12-07 11:35:32 -07:00
|
|
|
+ (BOOL)requiresMainQueueSetup
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2015-04-06 13:17:32 -06:00
|
|
|
@end
|