added ability to export video
This commit is contained in:
parent
18e8895712
commit
16e45fc9f1
6
Video.js
6
Video.js
@ -1,6 +1,6 @@
|
|||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {StyleSheet, requireNativeComponent, NativeModules, View, ViewPropTypes, Image, Platform} from 'react-native';
|
import {StyleSheet, requireNativeComponent, NativeModules, View, ViewPropTypes, Image, Platform, findNodeHandle} from 'react-native';
|
||||||
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
||||||
import TextTrackType from './TextTrackType';
|
import TextTrackType from './TextTrackType';
|
||||||
import VideoResizeMode from './VideoResizeMode.js';
|
import VideoResizeMode from './VideoResizeMode.js';
|
||||||
@ -71,6 +71,10 @@ export default class Video extends Component {
|
|||||||
this.setNativeProps({ fullscreen: false });
|
this.setNativeProps({ fullscreen: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
saveAsync = async (options?) => {
|
||||||
|
return await NativeModules.VideoManager.save(options, findNodeHandle(this._root));
|
||||||
|
}
|
||||||
|
|
||||||
_assignRoot = (component) => {
|
_assignRoot = (component) => {
|
||||||
this._root = component;
|
this._root = component;
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#import "RCTVideoPlayerViewController.h"
|
#import "RCTVideoPlayerViewController.h"
|
||||||
#import "RCTVideoPlayerViewControllerDelegate.h"
|
#import "RCTVideoPlayerViewControllerDelegate.h"
|
||||||
#import <React/RCTComponent.h>
|
#import <React/RCTComponent.h>
|
||||||
|
#import <React/RCTBridgeModule.h>
|
||||||
|
|
||||||
#if __has_include(<react-native-video/RCTVideoCache.h>)
|
#if __has_include(<react-native-video/RCTVideoCache.h>)
|
||||||
#import <react-native-video/RCTVideoCache.h>
|
#import <react-native-video/RCTVideoCache.h>
|
||||||
@ -41,4 +42,6 @@
|
|||||||
|
|
||||||
- (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem;
|
- (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem;
|
||||||
|
|
||||||
|
- (void)save:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
2036
ios/Video/RCTVideo.m
2036
ios/Video/RCTVideo.m
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
|||||||
#import <React/RCTViewManager.h>
|
#import <React/RCTViewManager.h>
|
||||||
|
#import <React/RCTBridgeModule.h>
|
||||||
|
|
||||||
@interface RCTVideoManager : RCTViewManager
|
@interface RCTVideoManager : RCTViewManager <RCTBridgeModule>
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
#import "RCTVideoManager.h"
|
#import "RCTVideoManager.h"
|
||||||
#import "RCTVideo.h"
|
#import "RCTVideo.h"
|
||||||
#import <React/RCTBridge.h>
|
#import <React/RCTBridge.h>
|
||||||
|
#import <React/RCTUIManager.h>
|
||||||
#import <AVFoundation/AVFoundation.h>
|
#import <AVFoundation/AVFoundation.h>
|
||||||
|
|
||||||
@implementation RCTVideoManager
|
@implementation RCTVideoManager
|
||||||
|
|
||||||
RCT_EXPORT_MODULE();
|
RCT_EXPORT_MODULE();
|
||||||
|
|
||||||
@synthesize bridge = _bridge;
|
|
||||||
|
|
||||||
- (UIView *)view
|
- (UIView *)view
|
||||||
{
|
{
|
||||||
return [[RCTVideo alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
return [[RCTVideo alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
||||||
@ -16,7 +15,7 @@ RCT_EXPORT_MODULE();
|
|||||||
|
|
||||||
- (dispatch_queue_t)methodQueue
|
- (dispatch_queue_t)methodQueue
|
||||||
{
|
{
|
||||||
return dispatch_get_main_queue();
|
return self.bridge.uiManager.methodQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_EXPORT_VIEW_PROPERTY(src, NSDictionary);
|
RCT_EXPORT_VIEW_PROPERTY(src, NSDictionary);
|
||||||
@ -59,6 +58,22 @@ RCT_EXPORT_VIEW_PROPERTY(onPlaybackStalled, RCTBubblingEventBlock);
|
|||||||
RCT_EXPORT_VIEW_PROPERTY(onPlaybackResume, RCTBubblingEventBlock);
|
RCT_EXPORT_VIEW_PROPERTY(onPlaybackResume, RCTBubblingEventBlock);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(onPlaybackRateChange, RCTBubblingEventBlock);
|
RCT_EXPORT_VIEW_PROPERTY(onPlaybackRateChange, RCTBubblingEventBlock);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(onVideoExternalPlaybackChange, RCTBubblingEventBlock);
|
RCT_EXPORT_VIEW_PROPERTY(onVideoExternalPlaybackChange, RCTBubblingEventBlock);
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(onVideoSaved, RCTBubblingEventBlock);
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary *)constantsToExport
|
- (NSDictionary *)constantsToExport
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user