mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Merge pull request #3271 from nextcloud/issue-3265
Fixed media recorder bug
This commit is contained in:
commit
a08c3bbe14
@ -348,6 +348,7 @@ class ChatActivity :
|
|||||||
AudioFormat.CHANNEL_IN_MONO,
|
AudioFormat.CHANNEL_IN_MONO,
|
||||||
AudioFormat.ENCODING_PCM_16BIT
|
AudioFormat.ENCODING_PCM_16BIT
|
||||||
)
|
)
|
||||||
|
private var voiceRecordDuration = 0L
|
||||||
|
|
||||||
// messy workaround for a mediaPlayer bug, don't delete
|
// messy workaround for a mediaPlayer bug, don't delete
|
||||||
private var lastRecordMediaPosition: Int = 0
|
private var lastRecordMediaPosition: Int = 0
|
||||||
@ -1163,7 +1164,7 @@ class ChatActivity :
|
|||||||
showRecordAudioUi(false)
|
showRecordAudioUi(false)
|
||||||
|
|
||||||
voiceRecordEndTime = System.currentTimeMillis()
|
voiceRecordEndTime = System.currentTimeMillis()
|
||||||
val voiceRecordDuration = voiceRecordEndTime - voiceRecordStartTime
|
voiceRecordDuration = voiceRecordEndTime - voiceRecordStartTime
|
||||||
if (voiceRecordDuration < MINIMUM_VOICE_RECORD_DURATION) {
|
if (voiceRecordDuration < MINIMUM_VOICE_RECORD_DURATION) {
|
||||||
Log.d(TAG, "voiceRecordDuration: $voiceRecordDuration")
|
Log.d(TAG, "voiceRecordDuration: $voiceRecordDuration")
|
||||||
Snackbar.make(
|
Snackbar.make(
|
||||||
@ -2075,6 +2076,7 @@ class ChatActivity :
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
start()
|
start()
|
||||||
|
Log.d(TAG, "recording started")
|
||||||
isVoiceRecordingInProgress = true
|
isVoiceRecordingInProgress = true
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
Log.e(TAG, "start for audio recording failed")
|
Log.e(TAG, "start for audio recording failed")
|
||||||
@ -2087,15 +2089,16 @@ class ChatActivity :
|
|||||||
private fun stopAndSendAudioRecording() {
|
private fun stopAndSendAudioRecording() {
|
||||||
if (isVoiceRecordingInProgress) {
|
if (isVoiceRecordingInProgress) {
|
||||||
stopAudioRecording()
|
stopAudioRecording()
|
||||||
|
Log.d(TAG, "stopped and sent audio recording")
|
||||||
|
val uri = Uri.fromFile(File(currentVoiceRecordFile))
|
||||||
|
uploadFile(uri.toString(), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
val uri = Uri.fromFile(File(currentVoiceRecordFile))
|
|
||||||
uploadFile(uri.toString(), true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopAndDiscardAudioRecording() {
|
private fun stopAndDiscardAudioRecording() {
|
||||||
if (isVoiceRecordingInProgress) {
|
if (isVoiceRecordingInProgress) {
|
||||||
stopAudioRecording()
|
stopAudioRecording()
|
||||||
|
Log.d(TAG, "stopped and discarded audio recording")
|
||||||
}
|
}
|
||||||
|
|
||||||
val cachedFile = File(currentVoiceRecordFile)
|
val cachedFile = File(currentVoiceRecordFile)
|
||||||
@ -2109,12 +2112,17 @@ class ChatActivity :
|
|||||||
|
|
||||||
recorder?.apply {
|
recorder?.apply {
|
||||||
try {
|
try {
|
||||||
stop()
|
Log.d(TAG, "recording stopped with $voiceRecordDuration")
|
||||||
|
if (voiceRecordDuration > MINIMUM_VOICE_RECORD_TO_STOP) {
|
||||||
|
stop()
|
||||||
|
}
|
||||||
release()
|
release()
|
||||||
isVoiceRecordingInProgress = false
|
isVoiceRecordingInProgress = false
|
||||||
Log.d(TAG, "stopped recorder. isVoiceRecordingInProgress = false")
|
Log.d(TAG, "stopped recorder. isVoiceRecordingInProgress = false")
|
||||||
} catch (e: java.lang.IllegalStateException) {
|
} catch (e: java.lang.IllegalStateException) {
|
||||||
error("error while stopping recorder!" + e)
|
error("error while stopping recorder!" + e)
|
||||||
|
} catch (e: java.lang.RuntimeException) {
|
||||||
|
error("error while stopping recorder!" + e)
|
||||||
}
|
}
|
||||||
|
|
||||||
VibrationUtils.vibrateShort(context)
|
VibrationUtils.vibrateShort(context)
|
||||||
@ -4241,6 +4249,7 @@ class ChatActivity :
|
|||||||
private const val REQUEST_CODE_SELECT_REMOTE_FILES = 888
|
private const val REQUEST_CODE_SELECT_REMOTE_FILES = 888
|
||||||
private const val OBJECT_MESSAGE: String = "{object}"
|
private const val OBJECT_MESSAGE: String = "{object}"
|
||||||
private const val MINIMUM_VOICE_RECORD_DURATION: Int = 1000
|
private const val MINIMUM_VOICE_RECORD_DURATION: Int = 1000
|
||||||
|
private const val MINIMUM_VOICE_RECORD_TO_STOP: Int = 200
|
||||||
private const val VOICE_RECORD_CANCEL_SLIDER_X: Int = -50
|
private const val VOICE_RECORD_CANCEL_SLIDER_X: Int = -50
|
||||||
private const val VOICE_RECORD_LOCK_BUTTON_Y: Int = -130
|
private const val VOICE_RECORD_LOCK_BUTTON_Y: Int = -130
|
||||||
private const val VOICE_MESSAGE_META_DATA = "{\"messageType\":\"voice-message\"}"
|
private const val VOICE_MESSAGE_META_DATA = "{\"messageType\":\"voice-message\"}"
|
||||||
|
Loading…
Reference in New Issue
Block a user