mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Improve player transitions
This commit is contained in:
parent
eb61a23bf6
commit
b41346cdce
1 changed files with 12 additions and 5 deletions
|
@ -63,10 +63,6 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
|||
|
||||
private var currentMediaPlayer: MediaPlayer? = null
|
||||
private var nextMediaPlayer: MediaPlayer? = null
|
||||
set(value) {
|
||||
field = value
|
||||
currentMediaPlayer?.setNextMediaPlayer(value)
|
||||
}
|
||||
private var currentSequence: Int? = null
|
||||
|
||||
private var fetchPlaylistJob: Job? = null
|
||||
|
@ -303,7 +299,7 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private inner class MediaPlayerListener : MediaPlayer.OnInfoListener, MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener {
|
||||
private inner class MediaPlayerListener : MediaPlayer.OnInfoListener, MediaPlayer.OnPreparedListener, MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener {
|
||||
|
||||
override fun onInfo(mp: MediaPlayer, what: Int, extra: Int): Boolean {
|
||||
when (what) {
|
||||
|
@ -317,6 +313,17 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
|||
return false
|
||||
}
|
||||
|
||||
override fun onPrepared(mp: MediaPlayer) {
|
||||
when (mp) {
|
||||
currentMediaPlayer -> {
|
||||
nextMediaPlayer?.let { mp.setNextMediaPlayer(it) }
|
||||
}
|
||||
nextMediaPlayer -> {
|
||||
tryOrNull { currentMediaPlayer?.setNextMediaPlayer(mp) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCompletion(mp: MediaPlayer) {
|
||||
if (nextMediaPlayer != null) return
|
||||
val roomId = currentRoomId ?: return
|
||||
|
|
Loading…
Reference in a new issue