From 41e2bed6b36f74a28d7dd640414c6d5ccbec0399 Mon Sep 17 00:00:00 2001 From: ashlyWeiting <52645850+ashlyWeiting@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:05:40 +0800 Subject: [PATCH] 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 --- .../main/java/com/brentvatne/common/api/ControlsConfig.kt | 2 ++ .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 8 +++++++- docs/pages/component/props.mdx | 2 ++ src/specs/VideoNativeComponent.ts | 1 + src/types/video.ts | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/brentvatne/common/api/ControlsConfig.kt b/android/src/main/java/com/brentvatne/common/api/ControlsConfig.kt index e03e5d4141..52736db2f3 100644 --- a/android/src/main/java/com/brentvatne/common/api/ControlsConfig.kt +++ b/android/src/main/java/com/brentvatne/common/api/ControlsConfig.kt @@ -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 diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 6f854efbe8..a3cee5e556 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -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, diff --git a/docs/pages/component/props.mdx b/docs/pages/component/props.mdx index b7e1a57726..30cc4b7b50 100644 --- a/docs/pages/component/props.mdx +++ b/docs/pages/component/props.mdx @@ -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, }} ``` diff --git a/src/specs/VideoNativeComponent.ts b/src/specs/VideoNativeComponent.ts index 546bf97d8e..25d2b48ef2 100644 --- a/src/specs/VideoNativeComponent.ts +++ b/src/specs/VideoNativeComponent.ts @@ -284,6 +284,7 @@ export type OnAudioFocusChangedData = Readonly<{ type ControlsStyles = Readonly<{ hideSeekBar?: boolean; + hideDuration?: boolean; seekIncrementMS?: Int32; }>; diff --git a/src/types/video.ts b/src/types/video.ts index eb075f9c1c..25915db4ec 100644 --- a/src/types/video.ts +++ b/src/types/video.ts @@ -223,6 +223,7 @@ export type AudioOutput = 'speaker' | 'earpiece'; export type ControlsStyles = { hideSeekBar?: boolean; + hideDuration?: boolean; seekIncrementMS?: number; };