mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
set playlist.currentSequence null by default
This commit is contained in:
parent
43a112839f
commit
266236c1e5
@ -296,7 +296,7 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
|||||||
override fun onInfo(mp: MediaPlayer, what: Int, extra: Int): Boolean {
|
override fun onInfo(mp: MediaPlayer, what: Int, extra: Int): Boolean {
|
||||||
when (what) {
|
when (what) {
|
||||||
MediaPlayer.MEDIA_INFO_STARTED_AS_NEXT -> {
|
MediaPlayer.MEDIA_INFO_STARTED_AS_NEXT -> {
|
||||||
playlist.currentSequence++
|
playlist.currentSequence = playlist.currentSequence?.inc()
|
||||||
currentMediaPlayer = mp
|
currentMediaPlayer = mp
|
||||||
nextMediaPlayer = null
|
nextMediaPlayer = null
|
||||||
prepareNextMediaPlayer()
|
prepareNextMediaPlayer()
|
||||||
|
@ -24,8 +24,8 @@ class VoiceBroadcastPlaylist(
|
|||||||
private val items: MutableList<PlaylistItem> = mutableListOf(),
|
private val items: MutableList<PlaylistItem> = mutableListOf(),
|
||||||
) : List<PlaylistItem> by items {
|
) : List<PlaylistItem> by items {
|
||||||
|
|
||||||
var currentSequence = 1
|
var currentSequence: Int? = null
|
||||||
val currentItem get() = findBySequence(currentSequence)
|
val currentItem get() = currentSequence?.let { findBySequence(it) }
|
||||||
|
|
||||||
val duration
|
val duration
|
||||||
get() = items.lastOrNull()?.let { it.startTime + it.audioEvent.duration } ?: 0
|
get() = items.lastOrNull()?.let { it.startTime + it.audioEvent.duration } ?: 0
|
||||||
@ -47,7 +47,7 @@ class VoiceBroadcastPlaylist(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
currentSequence = 1
|
currentSequence = null
|
||||||
items.clear()
|
items.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class VoiceBroadcastPlaylist(
|
|||||||
return items.find { it.audioEvent.sequence == sequenceNumber }
|
return items.find { it.audioEvent.sequence == sequenceNumber }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNextItem() = findBySequence(currentSequence.plus(1))
|
fun getNextItem() = findBySequence(currentSequence?.plus(1) ?: 1)
|
||||||
|
|
||||||
fun firstOrNull() = findBySequence(1)
|
fun firstOrNull() = findBySequence(1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user