Stop playback when deleting record on locked mode.

This commit is contained in:
Onuray Sahin 2021-07-23 16:53:34 +03:00
parent a11941714d
commit bd2ed4c58a
3 changed files with 5 additions and 1 deletions

View File

@ -631,6 +631,7 @@ class RoomDetailViewModel @AssistedInject constructor(
}
private fun handleEndRecordingVoiceMessage(isCancelled: Boolean) {
voiceMessageHelper.stopPlayback()
if (isCancelled) {
voiceMessageHelper.deleteRecording()
} else {

View File

@ -93,6 +93,7 @@ class VoiceMessageHelper @Inject constructor(
*/
fun pauseRecording() {
voiceRecorder.stopRecord()
stopRecordingAmplitudes()
}
fun deleteRecording() {
@ -112,6 +113,7 @@ class VoiceMessageHelper @Inject constructor(
fun startOrPausePlayback(id: String, file: File) {
stopPlayback()
stopRecordingAmplitudes()
if (playbackTracker.getPlaybackState(id) is VoiceMessagePlaybackTracker.Listener.State.Playing) {
playbackTracker.pausePlayback(id)
} else {
@ -145,7 +147,7 @@ class VoiceMessageHelper @Inject constructor(
startPlaybackTicker(id)
}
private fun stopPlayback() {
fun stopPlayback() {
mediaPlayer?.stop()
stopPlaybackTicker()
}

View File

@ -415,6 +415,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
val formattedTimerText = DateUtils.formatElapsedTime((state.playbackTime / 1000).toLong())
views.voicePlaybackTime.text = formattedTimerText
}
is VoiceMessagePlaybackTracker.Listener.State.Paused,
is VoiceMessagePlaybackTracker.Listener.State.Idle -> {
views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
}