Skip to content

Commit

Permalink
feat(android): support hiding Exoplayer video duration on android (#4090
Browse files Browse the repository at this point in the history
)

* feat: support for hiding duration on Android

* docs: add hideDuration property to control styles documentation
  • Loading branch information
ashlyWeiting authored Aug 21, 2024
1 parent 4611284 commit 41e2bed
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.facebook.react.bridge.ReadableMap
class ControlsConfig {
var hideSeekBar: Boolean = false
var seekIncrementMS: Int = 10000
var hideDuration: Boolean = false

companion object {
@JvmStatic
Expand All @@ -15,6 +16,7 @@ class ControlsConfig {
if (src != null) {
config.hideSeekBar = ReactBridgeUtils.safeGetBool(src, "hideSeekBar", false)
config.seekIncrementMS = ReactBridgeUtils.safeGetInt(src, "seekIncrementMS", 10000)
config.hideDuration = ReactBridgeUtils.safeGetBool(src, "hideDuration", false)
}

return config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,13 @@ private void refreshProgressBarVisibility (){
exoPosition.setLayoutParams(param);
}else{
exoProgress.setVisibility(VISIBLE);
exoDuration.setVisibility(VISIBLE);

if(controlsConfig.getHideDuration()){
exoDuration.setVisibility(GONE);
}else{
exoDuration.setVisibility(VISIBLE);
}

// Reset the layout parameters of exoPosition to their default state
LinearLayout.LayoutParams defaultParam = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
Expand Down
2 changes: 2 additions & 0 deletions docs/pages/component/props.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ Adjust the control styles. This prop is need only if `controls={true}` and is an
| Property | Type | Description |
|-----------------|---------|-----------------------------------------------------------------------------------------|
| hideSeekBar | boolean | The default value is `false`, allowing you to hide the seek bar for live broadcasts. |
| hideDuration | boolean | The default value is `false`, allowing you to hide the duration. |
| 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,
hideDuration: 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 @@ -284,6 +284,7 @@ export type OnAudioFocusChangedData = Readonly<{

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

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

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

Expand Down

0 comments on commit 41e2bed

Please sign in to comment.