From f9743fdbd66f5bb75e99b7eccda5ebcf9e2ab703 Mon Sep 17 00:00:00 2001 From: KrzysztofMoch Date: Fri, 22 Sep 2023 09:04:20 +0200 Subject: [PATCH] chore: invert `setPlayerPauseState` logic --- Video.js | 12 ++++++------ .../com/brentvatne/react/VideoManagerModule.java | 4 ++-- ios/Video/RCTVideoManager.m | 2 +- ios/Video/RCTVideoManager.swift | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Video.js b/Video.js index 10345246..44616b54 100644 --- a/Video.js +++ b/Video.js @@ -82,15 +82,15 @@ export default class Video extends Component { } pause = async () => { - await this.setPlayerPauseState(false); - }; - - play = async () => { await this.setPlayerPauseState(true); }; - setPlayerPauseState = async (shouldPlay) => { - return await NativeModules.VideoManager.setPlayerPauseState(shouldPlay, findNodeHandle(this._root)); + play = async () => { + await this.setPlayerPauseState(false); + }; + + setPlayerPauseState = async (paused) => { + return await NativeModules.VideoManager.setPlayerPauseState(paused, 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 ecc9a0bd..69106a47 100644 --- a/android/src/main/java/com/brentvatne/react/VideoManagerModule.java +++ b/android/src/main/java/com/brentvatne/react/VideoManagerModule.java @@ -20,14 +20,14 @@ public class VideoManagerModule extends ReactContextBaseJavaModule { } @ReactMethod - public void setPlayerPauseState(Boolean shouldPlay, int reactTag) { + public void setPlayerPauseState(Boolean paused, int reactTag) { UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); uiManager.prependUIBlock(manager -> { View view = manager.resolveView(reactTag); if (view instanceof ReactExoplayerView) { ReactExoplayerView videoView = (ReactExoplayerView) view; - videoView.setPausedModifier(!shouldPlay); + videoView.setPausedModifier(paused); } }); } diff --git a/ios/Video/RCTVideoManager.m b/ios/Video/RCTVideoManager.m index dee34128..2810f142 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(setPlayerPauseState:(nonnull NSNumber *)shouldPlay +RCT_EXTERN_METHOD(setPlayerPauseState:(nonnull NSNumber *)paused reactTag:(nonnull NSNumber *)reactTag) RCT_EXTERN_METHOD(presentFullscreenPlayer diff --git a/ios/Video/RCTVideoManager.swift b/ios/Video/RCTVideoManager.swift index ddfe4a9f..64e5eccd 100644 --- a/ios/Video/RCTVideoManager.swift +++ b/ios/Video/RCTVideoManager.swift @@ -72,14 +72,14 @@ class RCTVideoManager: RCTViewManager { } @objc(setPlayerPauseState:reactTag:) - func setPlayerPauseState(shouldPlay: NSNumber, reactTag: NSNumber) -> Void { + func setPlayerPauseState(paused: 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) + let paused = paused.boolValue + view.setPaused(paused) } }) }