feat(ios): add playback functions to ref
This commit is contained in:
parent
3f48c64364
commit
85c9e8f990
16
Video.js
16
Video.js
@ -14,8 +14,8 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { VideoDecoderProperties } = NativeModules
|
const { VideoDecoderProperties } = NativeModules;
|
||||||
export { TextTrackType, FilterType, DRMType, VideoDecoderProperties }
|
export { TextTrackType, FilterType, DRMType, VideoDecoderProperties };
|
||||||
|
|
||||||
export default class Video extends Component {
|
export default class Video extends Component {
|
||||||
|
|
||||||
@ -81,6 +81,18 @@ export default class Video extends Component {
|
|||||||
return await NativeModules.VideoManager.save(options, findNodeHandle(this._root));
|
return await NativeModules.VideoManager.save(options, findNodeHandle(this._root));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pause = async () => {
|
||||||
|
await this.setPlayerStatus(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
play = async () => {
|
||||||
|
await this.setPlayerStatus(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
setPlayerStatus = async (shouldPlay) => {
|
||||||
|
return await NativeModules.VideoManager.setPlayerStatus(shouldPlay, findNodeHandle(this._root));
|
||||||
|
};
|
||||||
|
|
||||||
restoreUserInterfaceForPictureInPictureStopCompleted = (restored) => {
|
restoreUserInterfaceForPictureInPictureStopCompleted = (restored) => {
|
||||||
this.setNativeProps({ restoreUserInterfaceForPIPStopCompletionHandler: restored });
|
this.setNativeProps({ restoreUserInterfaceForPIPStopCompletionHandler: restored });
|
||||||
};
|
};
|
||||||
|
@ -74,6 +74,9 @@ RCT_EXTERN_METHOD(setLicenseResult:(NSString *)license
|
|||||||
RCT_EXTERN_METHOD(setLicenseResultError(NSString *)error
|
RCT_EXTERN_METHOD(setLicenseResultError(NSString *)error
|
||||||
reactTag:(nonnull NSNumber *)reactTag)
|
reactTag:(nonnull NSNumber *)reactTag)
|
||||||
|
|
||||||
|
RCT_EXTERN_METHOD(setPlayerStatus:(nonnull NSNumber *)shouldPlay
|
||||||
|
reactTag:(nonnull NSNumber *)reactTag)
|
||||||
|
|
||||||
RCT_EXTERN_METHOD(presentFullscreenPlayer
|
RCT_EXTERN_METHOD(presentFullscreenPlayer
|
||||||
reactTag:(nonnull NSNumber *)reactTag)
|
reactTag:(nonnull NSNumber *)reactTag)
|
||||||
|
|
||||||
|
@ -71,6 +71,19 @@ class RCTVideoManager: RCTViewManager {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc(setPlayerStatus:reactTag:)
|
||||||
|
func setPlayerStatus(shouldPlay: NSNumber, reactTag: NSNumber) -> Void {
|
||||||
|
bridge.uiManager.prependUIBlock({_ , viewRegistry in
|
||||||
|
let view = viewRegistry?[reactTag]
|
||||||
|
if !(view is RCTVideo) {
|
||||||
|
RCTLogError("Invalid view returned from registry, expecting RCTVideo, got: %@", String(describing: view))
|
||||||
|
} else if let view = view as? RCTVideo {
|
||||||
|
let shouldPlay = shouldPlay.boolValue
|
||||||
|
view.setPaused(!shouldPlay)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
override func constantsToExport() -> [AnyHashable : Any]? {
|
override func constantsToExport() -> [AnyHashable : Any]? {
|
||||||
return [
|
return [
|
||||||
"ScaleNone": AVLayerVideoGravity.resizeAspect,
|
"ScaleNone": AVLayerVideoGravity.resizeAspect,
|
||||||
|
Loading…
Reference in New Issue
Block a user