diff --git a/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt b/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt index eba3fec6..42f2e77e 100644 --- a/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt +++ b/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt @@ -11,6 +11,7 @@ import com.bitmovin.player.api.Player import com.bitmovin.player.api.event.Event import com.bitmovin.player.api.event.PlayerEvent import com.bitmovin.player.api.event.SourceEvent +import com.bitmovin.player.api.ui.PlayerViewConfig import com.bitmovin.player.reactnative.converter.JsonConverter import com.bitmovin.player.reactnative.ui.RNPictureInPictureDelegate import com.bitmovin.player.reactnative.ui.RNPictureInPictureHandler @@ -149,6 +150,11 @@ class RNPlayerView(val context: ReactApplicationContext) : */ var pictureInPictureConfig: RNPictureInPictureHandler.PictureInPictureConfig? = null + /** + * Configures the visual presentation and behaviour of the [playerView]. + */ + var config: PlayerViewConfig? = null + /** * Whether this view should pause video playback when activity's onPause is called. * By default, `shouldPausePlaybackOnActivityPause` is set to false when entering PiP mode. diff --git a/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt b/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt index 51d06bc5..9a7e4557 100644 --- a/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt +++ b/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt @@ -6,6 +6,7 @@ import android.util.Log import android.view.ViewGroup.LayoutParams import com.bitmovin.player.PlayerView import com.bitmovin.player.api.ui.ScalingMode +import com.bitmovin.player.api.ui.PlayerViewConfig import com.bitmovin.player.reactnative.converter.JsonConverter import com.bitmovin.player.reactnative.extensions.getBooleanOrNull import com.bitmovin.player.reactnative.extensions.getModule @@ -187,6 +188,11 @@ class RNPlayerViewManager(private val context: ReactApplicationContext) : Simple view.pictureInPictureConfig = JsonConverter.toPictureInPictureConfig(pictureInPictureConfig) } + @ReactProp(name = "config") + fun setConfig(view: RNPlayerView, config: ReadableMap?) { + view.config = if (config != null) JsonConverter.toPlayerViewConfig(config) else null + } + private fun attachFullscreenBridge(view: RNPlayerView, fullscreenBridgeId: NativeId) { Handler(Looper.getMainLooper()).post { view.playerView?.setFullscreenHandler( @@ -261,7 +267,11 @@ class RNPlayerViewManager(private val context: ReactApplicationContext) : Simple Log.e(MODULE_NAME, "Cannot create a PlayerView, because no activity is attached.") return@post } - val playerView = PlayerView(currentActivity, player) + val playerView = PlayerView( + currentActivity, + player, + view.config ?: PlayerViewConfig(), + ) playerView.layoutParams = LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, diff --git a/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt b/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt index 486c6bba..f336ef41 100644 --- a/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt +++ b/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt @@ -39,8 +39,10 @@ import com.bitmovin.player.api.source.SourceConfig import com.bitmovin.player.api.source.SourceOptions import com.bitmovin.player.api.source.SourceType import com.bitmovin.player.api.source.TimelineReferencePoint +import com.bitmovin.player.api.ui.PlayerViewConfig import com.bitmovin.player.api.ui.ScalingMode import com.bitmovin.player.api.ui.StyleConfig +import com.bitmovin.player.api.ui.UiConfig import com.bitmovin.player.reactnative.BitmovinCastManagerOptions import com.bitmovin.player.reactnative.extensions.getBooleanOrNull import com.bitmovin.player.reactnative.extensions.getName @@ -1147,6 +1149,17 @@ class JsonConverter { isEnabled = it.getBoolean("isEnabled"), ) } + + /** + * Converts the [json] to a `RNUiConfig` object. + */ + fun toPlayerViewConfig(json: ReadableMap) = PlayerViewConfig( + uiConfig = UiConfig.WebUi( + playbackSpeedSelectionEnabled = json.getMap("uiConfig") + ?.getBooleanOrNull("playbackSpeedSelectionEnabled") + ?: true, + ), + ) } }