mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 09:55:40 +03:00
set playlist.currentSequence null by default
This commit is contained in:
parent
43a112839f
commit
266236c1e5
2 changed files with 5 additions and 5 deletions
|
@ -296,7 +296,7 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
|||
override fun onInfo(mp: MediaPlayer, what: Int, extra: Int): Boolean {
|
||||
when (what) {
|
||||
MediaPlayer.MEDIA_INFO_STARTED_AS_NEXT -> {
|
||||
playlist.currentSequence++
|
||||
playlist.currentSequence = playlist.currentSequence?.inc()
|
||||
currentMediaPlayer = mp
|
||||
nextMediaPlayer = null
|
||||
prepareNextMediaPlayer()
|
||||
|
|
|
@ -24,8 +24,8 @@ class VoiceBroadcastPlaylist(
|
|||
private val items: MutableList<PlaylistItem> = mutableListOf(),
|
||||
) : List<PlaylistItem> by items {
|
||||
|
||||
var currentSequence = 1
|
||||
val currentItem get() = findBySequence(currentSequence)
|
||||
var currentSequence: Int? = null
|
||||
val currentItem get() = currentSequence?.let { findBySequence(it) }
|
||||
|
||||
val duration
|
||||
get() = items.lastOrNull()?.let { it.startTime + it.audioEvent.duration } ?: 0
|
||||
|
@ -47,7 +47,7 @@ class VoiceBroadcastPlaylist(
|
|||
}
|
||||
|
||||
fun reset() {
|
||||
currentSequence = 1
|
||||
currentSequence = null
|
||||
items.clear()
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class VoiceBroadcastPlaylist(
|
|||
return items.find { it.audioEvent.sequence == sequenceNumber }
|
||||
}
|
||||
|
||||
fun getNextItem() = findBySequence(currentSequence.plus(1))
|
||||
fun getNextItem() = findBySequence(currentSequence?.plus(1) ?: 1)
|
||||
|
||||
fun firstOrNull() = findBySequence(1)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue