Skip to content

Commit

Permalink
feat(android): handle increment forward and rewind buttons (#3818)
Browse files Browse the repository at this point in the history
* feat(android): handle increment forward and rewind buttons
* fix: function name for get seekIncrementMS
  • Loading branch information
seyedmostafahasani authored May 28, 2024
1 parent 46e12e0 commit 5059e7a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.facebook.react.bridge.ReadableMap

class ControlsConfig {
var hideSeekBar: Boolean = false
var seekIncrementMS: Int = 10000

companion object {
@JvmStatic
Expand All @@ -13,6 +14,7 @@ class ControlsConfig {

if (src != null) {
config.hideSeekBar = ReactBridgeUtils.safeGetBool(src, "hideSeekBar", false)
config.seekIncrementMS = ReactBridgeUtils.safeGetInt(src, "seekIncrementMS", 10000)
}

return config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,17 @@ public void handleOnBackPressed() {
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
ImageButton pauseButton = playerControlView.findViewById(R.id.exo_pause);
pauseButton.setOnClickListener((View v) ->
Expand Down
8 changes: 5 additions & 3 deletions docs/pages/component/props.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ 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.

| Property | Type | Description |
|-------------|---------|--------------------------------------------------------------------------------------|
| hideSeekBar | boolean | The default value is `false`, allowing you to hide the seek bar for live broadcasts. |
| Property | Type | Description |
|-----------------|---------|-----------------------------------------------------------------------------------------|
| 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:

```javascript
controlsStyles={{
hideSeekBar: false,
seekIncrementMS: 10000,
}}
```

Expand Down
1 change: 1 addition & 0 deletions src/specs/VideoNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export type OnAudioFocusChangedData = Readonly<{

type ControlsStyles = Readonly<{
hideSeekBar?: boolean;
seekIncrementMS?: number;
}>;

export interface VideoNativeProps extends ViewProps {
Expand Down
1 change: 1 addition & 0 deletions src/types/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export type AudioOutput = 'speaker' | 'earpiece';

export type ControlsStyles = {
hideSeekBar?: boolean;
seekIncrementMS?: number;
};

export interface ReactVideoProps extends ReactVideoEvents, ViewProps {
Expand Down

0 comments on commit 5059e7a

Please sign in to comment.