feat(android): support hiding Exoplayer video duration on android (#4090)

* feat: support for hiding duration on Android

* docs: add hideDuration property to control styles documentation
This commit is contained in:
ashlyWeiting 2024-08-21 16:05:40 +08:00 committed by GitHub
parent 4611284247
commit 41e2bed6b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 1 deletions

View File

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

View File

@ -554,7 +554,13 @@ public class ReactExoplayerView extends FrameLayout implements
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,

View File

@ -147,6 +147,7 @@ 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:
@ -154,6 +155,7 @@ Example with default values:
```javascript
controlsStyles={{
hideSeekBar: false,
hideDuration: false,
seekIncrementMS: 10000,
}}
```

View File

@ -284,6 +284,7 @@ export type OnAudioFocusChangedData = Readonly<{
type ControlsStyles = Readonly<{
hideSeekBar?: boolean;
hideDuration?: boolean;
seekIncrementMS?: Int32;
}>;

View File

@ -223,6 +223,7 @@ export type AudioOutput = 'speaker' | 'earpiece';
export type ControlsStyles = {
hideSeekBar?: boolean;
hideDuration?: boolean;
seekIncrementMS?: number;
};