diff --git a/API.md b/API.md index 6130bdb9..aa4a2458 100644 --- a/API.md +++ b/API.md @@ -1643,19 +1643,6 @@ this.player.seek(120, 50); // Seek to 2 minutes with +/- 50 milliseconds accurac Platforms: iOS -### setPlayerStatus -`setPlayerStatus(shouldPlay: boolean): Promise` - -Play/Pause the video. - -Example: -``` -this.player.setPlayerStatus(true); // Play the video -this.player.setPlayerStatus(false); // Pause the video -``` - -platforms: Android, iOS - ### pause `pause(): Promise` @@ -1666,8 +1653,6 @@ Example: this.player.pause(); ``` -NOTE: This is the same as calling `setPlayerStatus(false)` - Platforms: Android, iOS ### play @@ -1680,8 +1665,6 @@ Example: this.player.play(); ``` -NOTE: This is the same as calling `setPlayerStatus(true)` - Platforms: Android, iOS #### Static methods diff --git a/Video.js b/Video.js index f29cd4d7..10345246 100644 --- a/Video.js +++ b/Video.js @@ -82,15 +82,15 @@ export default class Video extends Component { } pause = async () => { - await this.setPlayerStatus(false); + await this.setPlayerPauseState(false); }; play = async () => { - await this.setPlayerStatus(true); + await this.setPlayerPauseState(true); }; - setPlayerStatus = async (shouldPlay) => { - return await NativeModules.VideoManager.setPlayerStatus(shouldPlay, findNodeHandle(this._root)); + setPlayerPauseState = async (shouldPlay) => { + return await NativeModules.VideoManager.setPlayerPauseState(shouldPlay, findNodeHandle(this._root)); }; restoreUserInterfaceForPictureInPictureStopCompleted = (restored) => { diff --git a/android/src/main/java/com/brentvatne/react/VideoManagerModule.java b/android/src/main/java/com/brentvatne/react/VideoManagerModule.java index bf5b6c1f..ecc9a0bd 100644 --- a/android/src/main/java/com/brentvatne/react/VideoManagerModule.java +++ b/android/src/main/java/com/brentvatne/react/VideoManagerModule.java @@ -20,7 +20,7 @@ public class VideoManagerModule extends ReactContextBaseJavaModule { } @ReactMethod - public void setPlayerStatus(Boolean shouldPlay, int reactTag) { + public void setPlayerPauseState(Boolean shouldPlay, int reactTag) { UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); uiManager.prependUIBlock(manager -> { View view = manager.resolveView(reactTag); diff --git a/examples/basic/src/VideoPlayer.android.tsx b/examples/basic/src/VideoPlayer.android.tsx index a62ac563..750d963a 100644 --- a/examples/basic/src/VideoPlayer.android.tsx +++ b/examples/basic/src/VideoPlayer.android.tsx @@ -728,11 +728,10 @@ class VideoPlayer extends Component { } const {paused} = this.state; - const {pause, play, setPlayerStatus} = this.video.current; + const {pause, play} = this.video.current; const shouldPlay = paused === true || paused === undefined; shouldPlay ? play() : pause(); - // OR setPlayerStatus(shouldPlay); this.setState({paused: !shouldPlay}); }}> diff --git a/examples/basic/src/VideoPlayer.ios.tsx b/examples/basic/src/VideoPlayer.ios.tsx index 26386cb9..d5bd2d74 100644 --- a/examples/basic/src/VideoPlayer.ios.tsx +++ b/examples/basic/src/VideoPlayer.ios.tsx @@ -235,11 +235,10 @@ class VideoPlayer extends Component { return; } - const {play, pause, setPlayerStatus} = this.video.current; + const {play, pause} = this.video.current; const shouldPlay = !this.state.paused; shouldPlay ? play() : pause(); - // OR setPlayerStatus(shouldPlay) this.setState({paused: shouldPlay}); }}> diff --git a/ios/Video/RCTVideoManager.m b/ios/Video/RCTVideoManager.m index 83f49c4d..dee34128 100644 --- a/ios/Video/RCTVideoManager.m +++ b/ios/Video/RCTVideoManager.m @@ -74,7 +74,7 @@ RCT_EXTERN_METHOD(setLicenseResult:(NSString *)license RCT_EXTERN_METHOD(setLicenseResultError(NSString *)error reactTag:(nonnull NSNumber *)reactTag) -RCT_EXTERN_METHOD(setPlayerStatus:(nonnull NSNumber *)shouldPlay +RCT_EXTERN_METHOD(setPlayerPauseState:(nonnull NSNumber *)shouldPlay reactTag:(nonnull NSNumber *)reactTag) RCT_EXTERN_METHOD(presentFullscreenPlayer diff --git a/ios/Video/RCTVideoManager.swift b/ios/Video/RCTVideoManager.swift index 3e118d3c..ddfe4a9f 100644 --- a/ios/Video/RCTVideoManager.swift +++ b/ios/Video/RCTVideoManager.swift @@ -71,8 +71,8 @@ class RCTVideoManager: RCTViewManager { }) } - @objc(setPlayerStatus:reactTag:) - func setPlayerStatus(shouldPlay: NSNumber, reactTag: NSNumber) -> Void { + @objc(setPlayerPauseState:reactTag:) + func setPlayerPauseState(shouldPlay: NSNumber, reactTag: NSNumber) -> Void { bridge.uiManager.prependUIBlock({_ , viewRegistry in let view = viewRegistry?[reactTag] if !(view is RCTVideo) {