diff --git a/app/src/main/java/com/streamamg/playback_sdk_android_app/CustomVideoPlayerPlugin.kt b/app/src/main/java/com/streamamg/playback_sdk_android_app/CustomVideoPlayerPlugin.kt index d386386..2d2f1d3 100644 --- a/app/src/main/java/com/streamamg/playback_sdk_android_app/CustomVideoPlayerPlugin.kt +++ b/app/src/main/java/com/streamamg/playback_sdk_android_app/CustomVideoPlayerPlugin.kt @@ -14,6 +14,7 @@ import com.streamamg.player.plugin.VideoPlayerConfig class NativeMediaPlayerPlugin : VideoPlayerPlugin { private var mediaPlayer: MediaPlayer? = null + private var playerConfig = VideoPlayerConfig() override val name: String get() = "Native Media Player Plugin" @@ -21,15 +22,13 @@ class NativeMediaPlayerPlugin : VideoPlayerPlugin { get() = "1.0" override fun setup(config: VideoPlayerConfig) { - mediaPlayer = MediaPlayer() + playerConfig.playbackConfig.autoplayEnabled = config.playbackConfig.autoplayEnabled + playerConfig.playbackConfig.backgroundPlaybackEnabled = config.playbackConfig.backgroundPlaybackEnabled } @Composable override fun PlayerView(hlsUrl: String): Unit { - val config = VideoPlayerConfig() - config.playbackConfig.autoplayEnabled = true - config.playbackConfig.backgroundPlaybackEnabled = false - setup(config) + mediaPlayer = MediaPlayer() val textureView = rememberTextureView() @@ -39,7 +38,9 @@ class NativeMediaPlayerPlugin : VideoPlayerPlugin { // When MediaPlayer is prepared, set the surface texture textureView.surfaceTexture?.let { mp.setSurface(Surface(it)) - mp.start() + if (playerConfig.playbackConfig.autoplayEnabled) { + mp.start() + } } } prepareAsync() diff --git a/playback-sdk-android/src/main/java/com/streamamg/player/plugin/bitmovin/BitmovinVideoPlayerPlugin.kt b/playback-sdk-android/src/main/java/com/streamamg/player/plugin/bitmovin/BitmovinVideoPlayerPlugin.kt index fc50384..e801363 100644 --- a/playback-sdk-android/src/main/java/com/streamamg/player/plugin/bitmovin/BitmovinVideoPlayerPlugin.kt +++ b/playback-sdk-android/src/main/java/com/streamamg/player/plugin/bitmovin/BitmovinVideoPlayerPlugin.kt @@ -46,7 +46,7 @@ class BitmovinVideoPlayerPlugin : VideoPlayerPlugin { private lateinit var hlsUrl: String private lateinit var playerView: PlayerView - var playerConfig = VideoPlayerConfig() + private var playerConfig = VideoPlayerConfig() private var playerBind: Player? = null private var bound = false private val fullscreen = mutableStateOf(false)