Voice Broadcast - Introduce listening actions
This commit is contained in:
parent
eb44b02228
commit
2760781f0a
@ -121,9 +121,17 @@ sealed class RoomDetailAction : VectorViewModelAction {
|
|||||||
object OpenElementCallWidget : RoomDetailAction()
|
object OpenElementCallWidget : RoomDetailAction()
|
||||||
|
|
||||||
sealed class VoiceBroadcastAction : RoomDetailAction() {
|
sealed class VoiceBroadcastAction : RoomDetailAction() {
|
||||||
object Start : VoiceBroadcastAction()
|
sealed class Recording : VoiceBroadcastAction() {
|
||||||
object Pause : VoiceBroadcastAction()
|
object Start : Recording()
|
||||||
object Resume : VoiceBroadcastAction()
|
object Pause : Recording()
|
||||||
object Stop : VoiceBroadcastAction()
|
object Resume : Recording()
|
||||||
|
object Stop : Recording()
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class Listening : VoiceBroadcastAction() {
|
||||||
|
data class PlayOrResume(val eventId: String) : Listening()
|
||||||
|
object Pause : Listening()
|
||||||
|
object Stop : Listening()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -604,10 +604,13 @@ class TimelineViewModel @AssistedInject constructor(
|
|||||||
if (room == null) return
|
if (room == null) return
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
when (action) {
|
when (action) {
|
||||||
RoomDetailAction.VoiceBroadcastAction.Start -> voiceBroadcastHelper.startVoiceBroadcast(room.roomId)
|
RoomDetailAction.VoiceBroadcastAction.Recording.Start -> voiceBroadcastHelper.startVoiceBroadcast(room.roomId)
|
||||||
RoomDetailAction.VoiceBroadcastAction.Pause -> voiceBroadcastHelper.pauseVoiceBroadcast(room.roomId)
|
RoomDetailAction.VoiceBroadcastAction.Recording.Pause -> voiceBroadcastHelper.pauseVoiceBroadcast(room.roomId)
|
||||||
RoomDetailAction.VoiceBroadcastAction.Resume -> voiceBroadcastHelper.resumeVoiceBroadcast(room.roomId)
|
RoomDetailAction.VoiceBroadcastAction.Recording.Resume -> voiceBroadcastHelper.resumeVoiceBroadcast(room.roomId)
|
||||||
RoomDetailAction.VoiceBroadcastAction.Stop -> voiceBroadcastHelper.stopVoiceBroadcast(room.roomId)
|
RoomDetailAction.VoiceBroadcastAction.Recording.Stop -> voiceBroadcastHelper.stopVoiceBroadcast(room.roomId)
|
||||||
|
is RoomDetailAction.VoiceBroadcastAction.Listening.PlayOrResume -> voiceBroadcastHelper.playOrResumePlayback(room.roomId, action.eventId)
|
||||||
|
RoomDetailAction.VoiceBroadcastAction.Listening.Pause -> voiceBroadcastHelper.pausePlayback()
|
||||||
|
RoomDetailAction.VoiceBroadcastAction.Listening.Stop -> voiceBroadcastHelper.stopPlayback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
|
|||||||
}
|
}
|
||||||
// TODO remove this when there will be a recording indicator outside of the timeline
|
// TODO remove this when there will be a recording indicator outside of the timeline
|
||||||
// Pause voice broadcast if the timeline is not shown anymore
|
// Pause voice broadcast if the timeline is not shown anymore
|
||||||
it.isVoiceBroadcasting && !requireActivity().isChangingConfigurations -> timelineViewModel.handle(VoiceBroadcastAction.Pause)
|
it.isVoiceBroadcasting && !requireActivity().isChangingConfigurations -> timelineViewModel.handle(VoiceBroadcastAction.Recording.Pause)
|
||||||
else -> {
|
else -> {
|
||||||
messageComposerViewModel.handle(MessageComposerAction.OnEntersBackground(composer.text.toString()))
|
messageComposerViewModel.handle(MessageComposerAction.OnEntersBackground(composer.text.toString()))
|
||||||
}
|
}
|
||||||
@ -684,7 +684,7 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
|
|||||||
locationOwnerId = session.myUserId
|
locationOwnerId = session.myUserId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
AttachmentTypeSelectorView.Type.VOICE_BROADCAST -> timelineViewModel.handle(VoiceBroadcastAction.Start)
|
AttachmentTypeSelectorView.Type.VOICE_BROADCAST -> timelineViewModel.handle(VoiceBroadcastAction.Recording.Start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021 New Vector Ltd
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -30,6 +30,7 @@ class VoiceBroadcastHelper @Inject constructor(
|
|||||||
private val pauseVoiceBroadcastUseCase: PauseVoiceBroadcastUseCase,
|
private val pauseVoiceBroadcastUseCase: PauseVoiceBroadcastUseCase,
|
||||||
private val resumeVoiceBroadcastUseCase: ResumeVoiceBroadcastUseCase,
|
private val resumeVoiceBroadcastUseCase: ResumeVoiceBroadcastUseCase,
|
||||||
private val stopVoiceBroadcastUseCase: StopVoiceBroadcastUseCase,
|
private val stopVoiceBroadcastUseCase: StopVoiceBroadcastUseCase,
|
||||||
|
private val voiceBroadcastPlayer: VoiceBroadcastPlayer,
|
||||||
) {
|
) {
|
||||||
suspend fun startVoiceBroadcast(roomId: String) = startVoiceBroadcastUseCase.execute(roomId)
|
suspend fun startVoiceBroadcast(roomId: String) = startVoiceBroadcastUseCase.execute(roomId)
|
||||||
|
|
||||||
@ -38,4 +39,10 @@ class VoiceBroadcastHelper @Inject constructor(
|
|||||||
suspend fun resumeVoiceBroadcast(roomId: String) = resumeVoiceBroadcastUseCase.execute(roomId)
|
suspend fun resumeVoiceBroadcast(roomId: String) = resumeVoiceBroadcastUseCase.execute(roomId)
|
||||||
|
|
||||||
suspend fun stopVoiceBroadcast(roomId: String) = stopVoiceBroadcastUseCase.execute(roomId)
|
suspend fun stopVoiceBroadcast(roomId: String) = stopVoiceBroadcastUseCase.execute(roomId)
|
||||||
|
|
||||||
|
fun playOrResumePlayback(roomId: String, eventId: String) = voiceBroadcastPlayer.play(roomId, eventId)
|
||||||
|
|
||||||
|
fun pausePlayback() = voiceBroadcastPlayer.pause()
|
||||||
|
|
||||||
|
fun stopPlayback() = voiceBroadcastPlayer.stop()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user