mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 12:18:48 +03:00
VoiceBroadcastRecorder - Improve recorder by sending chunk when pausing
This commit is contained in:
parent
e9c81ca98f
commit
f05f0a85b0
1 changed files with 14 additions and 0 deletions
|
@ -21,6 +21,7 @@ import android.media.MediaRecorder
|
|||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import im.vector.app.features.voice.AbstractVoiceRecorderQ
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.session.content.ContentAttachmentData
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
|
@ -30,6 +31,7 @@ class VoiceBroadcastRecorderQ(
|
|||
|
||||
private var maxFileSize = 0L // zero or negative for no limit
|
||||
private var currentSequence = 0
|
||||
private var currentRoomId: String? = null
|
||||
|
||||
override var listener: VoiceBroadcastRecorder.Listener? = null
|
||||
|
||||
|
@ -51,11 +53,23 @@ class VoiceBroadcastRecorderQ(
|
|||
}
|
||||
|
||||
override fun startRecord(roomId: String, chunkLength: Int) {
|
||||
currentRoomId = roomId
|
||||
maxFileSize = (chunkLength * audioEncodingBitRate / 8).toLong()
|
||||
currentSequence = 1
|
||||
startRecord(roomId)
|
||||
}
|
||||
|
||||
override fun pauseRecord() {
|
||||
tryOrNull { mediaRecorder?.stop() }
|
||||
mediaRecorder?.reset()
|
||||
notifyOutputFileCreated()
|
||||
}
|
||||
|
||||
override fun resumeRecord() {
|
||||
currentSequence++
|
||||
currentRoomId?.let { startRecord(it) }
|
||||
}
|
||||
|
||||
override fun stopRecord() {
|
||||
super.stopRecord()
|
||||
notifyOutputFileCreated()
|
||||
|
|
Loading…
Add table
Reference in a new issue