Skip to content

Commit

Permalink
ZEUS-4391 Background audio
Browse files Browse the repository at this point in the history
- Fixed player config and autoplay on Custom Video player plugin
- Player config as private variable on Bitmovin plugin
  • Loading branch information
Stefano Russello committed Jul 12, 2024
1 parent 5000691 commit 41f6a95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ 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"
override val version: String
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()

Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 41f6a95

Please sign in to comment.