chore: invert setPlayerPauseState logic

This commit is contained in:
KrzysztofMoch 2023-09-22 09:04:20 +02:00
parent 106257aa80
commit f9743fdbd6
4 changed files with 12 additions and 12 deletions

View File

@ -82,15 +82,15 @@ export default class Video extends Component {
} }
pause = async () => { pause = async () => {
await this.setPlayerPauseState(false);
};
play = async () => {
await this.setPlayerPauseState(true); await this.setPlayerPauseState(true);
}; };
setPlayerPauseState = async (shouldPlay) => { play = async () => {
return await NativeModules.VideoManager.setPlayerPauseState(shouldPlay, findNodeHandle(this._root)); await this.setPlayerPauseState(false);
};
setPlayerPauseState = async (paused) => {
return await NativeModules.VideoManager.setPlayerPauseState(paused, findNodeHandle(this._root));
}; };
restoreUserInterfaceForPictureInPictureStopCompleted = (restored) => { restoreUserInterfaceForPictureInPictureStopCompleted = (restored) => {

View File

@ -20,14 +20,14 @@ public class VideoManagerModule extends ReactContextBaseJavaModule {
} }
@ReactMethod @ReactMethod
public void setPlayerPauseState(Boolean shouldPlay, int reactTag) { public void setPlayerPauseState(Boolean paused, int reactTag) {
UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class);
uiManager.prependUIBlock(manager -> { uiManager.prependUIBlock(manager -> {
View view = manager.resolveView(reactTag); View view = manager.resolveView(reactTag);
if (view instanceof ReactExoplayerView) { if (view instanceof ReactExoplayerView) {
ReactExoplayerView videoView = (ReactExoplayerView) view; ReactExoplayerView videoView = (ReactExoplayerView) view;
videoView.setPausedModifier(!shouldPlay); videoView.setPausedModifier(paused);
} }
}); });
} }

View File

@ -74,7 +74,7 @@ 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(setPlayerPauseState:(nonnull NSNumber *)shouldPlay RCT_EXTERN_METHOD(setPlayerPauseState:(nonnull NSNumber *)paused
reactTag:(nonnull NSNumber *)reactTag) reactTag:(nonnull NSNumber *)reactTag)
RCT_EXTERN_METHOD(presentFullscreenPlayer RCT_EXTERN_METHOD(presentFullscreenPlayer

View File

@ -72,14 +72,14 @@ class RCTVideoManager: RCTViewManager {
} }
@objc(setPlayerPauseState:reactTag:) @objc(setPlayerPauseState:reactTag:)
func setPlayerPauseState(shouldPlay: NSNumber, reactTag: NSNumber) -> Void { func setPlayerPauseState(paused: NSNumber, reactTag: NSNumber) -> Void {
bridge.uiManager.prependUIBlock({_ , viewRegistry in bridge.uiManager.prependUIBlock({_ , viewRegistry in
let view = viewRegistry?[reactTag] let view = viewRegistry?[reactTag]
if !(view is RCTVideo) { if !(view is RCTVideo) {
RCTLogError("Invalid view returned from registry, expecting RCTVideo, got: %@", String(describing: view)) RCTLogError("Invalid view returned from registry, expecting RCTVideo, got: %@", String(describing: view))
} else if let view = view as? RCTVideo { } else if let view = view as? RCTVideo {
let shouldPlay = shouldPlay.boolValue let paused = paused.boolValue
view.setPaused(!shouldPlay) view.setPaused(paused)
} }
}) })
} }