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 () => {
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) => {

View File

@ -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);
}
});
}

View File

@ -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

View File

@ -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)
}
})
}