chore: rename setPlayerStatus to setPlayerPauseState

This commit is contained in:
KrzysztofMoch 2023-09-21 07:25:21 +02:00
parent 01ce04c7ac
commit 421712825b
7 changed files with 10 additions and 29 deletions

17
API.md
View File

@ -1643,19 +1643,6 @@ this.player.seek(120, 50); // Seek to 2 minutes with +/- 50 milliseconds accurac
Platforms: iOS
### setPlayerStatus
`setPlayerStatus(shouldPlay: boolean): Promise<void>`
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<void>`
@ -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

View File

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

View File

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

View File

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

View File

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

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(setPlayerStatus:(nonnull NSNumber *)shouldPlay
RCT_EXTERN_METHOD(setPlayerPauseState:(nonnull NSNumber *)shouldPlay
reactTag:(nonnull NSNumber *)reactTag)
RCT_EXTERN_METHOD(presentFullscreenPlayer

View File

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