feat(android): handle increment forward and rewind buttons (#3818)

* feat(android): handle increment forward and rewind buttons
* fix: function name for get seekIncrementMS
This commit is contained in:
Seyed Mostafa Hasani 2024-05-28 00:32:30 -07:00 committed by GitHub
parent 46e12e0b94
commit 5059e7a7f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import com.facebook.react.bridge.ReadableMap
class ControlsConfig { class ControlsConfig {
var hideSeekBar: Boolean = false var hideSeekBar: Boolean = false
var seekIncrementMS: Int = 10000
companion object { companion object {
@JvmStatic @JvmStatic
@ -13,6 +14,7 @@ class ControlsConfig {
if (src != null) { if (src != null) {
config.hideSeekBar = ReactBridgeUtils.safeGetBool(src, "hideSeekBar", false) config.hideSeekBar = ReactBridgeUtils.safeGetBool(src, "hideSeekBar", false)
config.seekIncrementMS = ReactBridgeUtils.safeGetInt(src, "seekIncrementMS", 10000)
} }
return config return config

View File

@ -444,6 +444,17 @@ public class ReactExoplayerView extends FrameLayout implements
setPausedModifier(false); setPausedModifier(false);
}); });
//Handling the rewind and forward button click events
ImageButton exoRewind = playerControlView.findViewById(R.id.exo_rew);
ImageButton exoForward = playerControlView.findViewById(R.id.exo_ffwd);
exoRewind.setOnClickListener((View v) -> {
seekTo(player.getCurrentPosition() - controlsConfig.getSeekIncrementMS());
});
exoForward.setOnClickListener((View v) -> {
seekTo(player.getCurrentPosition() + controlsConfig.getSeekIncrementMS());
});
//Handling the pauseButton click event //Handling the pauseButton click event
ImageButton pauseButton = playerControlView.findViewById(R.id.exo_pause); ImageButton pauseButton = playerControlView.findViewById(R.id.exo_pause);
pauseButton.setOnClickListener((View v) -> pauseButton.setOnClickListener((View v) ->

View File

@ -54,14 +54,16 @@ A Boolean value that indicates whether the player should automatically delay pla
Adjust the control styles. This prop is need only if `controls={true}` and is an object. See the list of prop supported below. Adjust the control styles. This prop is need only if `controls={true}` and is an object. See the list of prop supported below.
| Property | Type | Description | | Property | Type | Description |
|-------------|---------|--------------------------------------------------------------------------------------| |-----------------|---------|-----------------------------------------------------------------------------------------|
| hideSeekBar | boolean | The default value is `false`, allowing you to hide the seek bar for live broadcasts. | | hideSeekBar | boolean | The default value is `false`, allowing you to hide the seek bar for live broadcasts. |
| seekIncrementMS | number | The default value is `10000`. You can change the value to increment forward and rewind. |
Example with default values: Example with default values:
```javascript ```javascript
controlsStyles={{ controlsStyles={{
hideSeekBar: false, hideSeekBar: false,
seekIncrementMS: 10000,
}} }}
``` ```

View File

@ -285,6 +285,7 @@ export type OnAudioFocusChangedData = Readonly<{
type ControlsStyles = Readonly<{ type ControlsStyles = Readonly<{
hideSeekBar?: boolean; hideSeekBar?: boolean;
seekIncrementMS?: number;
}>; }>;
export interface VideoNativeProps extends ViewProps { export interface VideoNativeProps extends ViewProps {

View File

@ -204,6 +204,7 @@ export type AudioOutput = 'speaker' | 'earpiece';
export type ControlsStyles = { export type ControlsStyles = {
hideSeekBar?: boolean; hideSeekBar?: boolean;
seekIncrementMS?: number;
}; };
export interface ReactVideoProps extends ReactVideoEvents, ViewProps { export interface ReactVideoProps extends ReactVideoEvents, ViewProps {