From 9b97d8b9dbded5a4fb1f7a2388430ac298faca46 Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Sun, 9 Jun 2024 17:22:56 -0400 Subject: [PATCH] Add amplitudes to RecordingUpdate to be passed back to caller --- .../java/org/wordpress/android/util/audio/AudioRecorder.kt | 2 ++ .../java/org/wordpress/android/util/audio/RecordingUpdate.kt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/audio/AudioRecorder.kt b/WordPress/src/main/java/org/wordpress/android/util/audio/AudioRecorder.kt index 7b6f73ad6d90..283d18593793 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/audio/AudioRecorder.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/audio/AudioRecorder.kt @@ -150,10 +150,12 @@ class AudioRecorder( delay(RECORDING_UPDATE_INTERVAL) elapsedTimeInSeconds += (RECORDING_UPDATE_INTERVAL / 1000).toInt() val fileSize = File(filePath).length() + val amplitude = recorder?.maxAmplitude?.toFloat() ?: 0f _recordingUpdates.value = RecordingUpdate( elapsedTime = elapsedTimeInSeconds, fileSize = fileSize, fileSizeLimitExceeded = fileSize >= recordingStrategy.maxFileSize, + amplitudes = listOf(amplitude) ) if ( maxFileSizeExceeded(fileSize) || maxDurationExceeded(elapsedTimeInSeconds) ) { diff --git a/WordPress/src/main/java/org/wordpress/android/util/audio/RecordingUpdate.kt b/WordPress/src/main/java/org/wordpress/android/util/audio/RecordingUpdate.kt index fbd7ceabce38..f067d6cff8a4 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/audio/RecordingUpdate.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/audio/RecordingUpdate.kt @@ -3,5 +3,6 @@ package org.wordpress.android.util.audio data class RecordingUpdate( val elapsedTime: Int = 0, // in seconds val fileSize: Long = 0L, // in bytes - val fileSizeLimitExceeded: Boolean = false + val fileSizeLimitExceeded: Boolean = false, + val amplitudes: List = emptyList() )