mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Fix null voiceBroadcastId when the playlist is empty
This commit is contained in:
parent
cebc096ac7
commit
9c5b6d8207
1 changed files with 5 additions and 5 deletions
|
@ -30,7 +30,6 @@ import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.events.model.RelationType
|
import org.matrix.android.sdk.api.session.events.model.RelationType
|
||||||
import org.matrix.android.sdk.api.session.events.model.getRelationContent
|
|
||||||
import org.matrix.android.sdk.api.session.getRoom
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent
|
||||||
|
@ -73,8 +72,7 @@ class VoiceBroadcastPlayer @Inject constructor(
|
||||||
private var currentSequence: Int? = null
|
private var currentSequence: Int? = null
|
||||||
|
|
||||||
private var playlist = emptyList<MessageAudioEvent>()
|
private var playlist = emptyList<MessageAudioEvent>()
|
||||||
val currentVoiceBroadcastId
|
var currentVoiceBroadcastId: String? = null
|
||||||
get() = playlist.firstOrNull()?.root?.getRelationContent()?.eventId
|
|
||||||
|
|
||||||
private var state: State = State.IDLE
|
private var state: State = State.IDLE
|
||||||
set(value) {
|
set(value) {
|
||||||
|
@ -128,6 +126,7 @@ class VoiceBroadcastPlayer @Inject constructor(
|
||||||
playlist = emptyList()
|
playlist = emptyList()
|
||||||
currentSequence = null
|
currentSequence = null
|
||||||
currentRoomId = null
|
currentRoomId = null
|
||||||
|
currentVoiceBroadcastId = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addListener(listener: Listener) {
|
fun addListener(listener: Listener) {
|
||||||
|
@ -141,11 +140,12 @@ class VoiceBroadcastPlayer @Inject constructor(
|
||||||
|
|
||||||
private fun startPlayback(roomId: String, eventId: String) {
|
private fun startPlayback(roomId: String, eventId: String) {
|
||||||
val room = session.getRoom(roomId) ?: error("Unknown roomId: $roomId")
|
val room = session.getRoom(roomId) ?: error("Unknown roomId: $roomId")
|
||||||
currentRoomId = roomId
|
|
||||||
|
|
||||||
// Stop listening previous voice broadcast if any
|
// Stop listening previous voice broadcast if any
|
||||||
if (state != State.IDLE) stop()
|
if (state != State.IDLE) stop()
|
||||||
|
|
||||||
|
currentRoomId = roomId
|
||||||
|
currentVoiceBroadcastId = eventId
|
||||||
|
|
||||||
state = State.BUFFERING
|
state = State.BUFFERING
|
||||||
|
|
||||||
val voiceBroadcastState = getVoiceBroadcastUseCase.execute(roomId, eventId)?.content?.voiceBroadcastState
|
val voiceBroadcastState = getVoiceBroadcastUseCase.execute(roomId, eventId)?.content?.voiceBroadcastState
|
||||||
|
|
Loading…
Reference in a new issue