|
|
|
@ -185,7 +185,6 @@ class AudioRecorderManager { |
|
|
|
@Volatile var elapsedMs: Int = 0; private set |
|
|
|
@Volatile var elapsedMs: Int = 0; private set |
|
|
|
var pausedElapsedMs: Int = 0; private set |
|
|
|
var pausedElapsedMs: Int = 0; private set |
|
|
|
private var playThread: Thread? = null |
|
|
|
private var playThread: Thread? = null |
|
|
|
private var currentPlayPath: String? = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun playVoiceFile(filePath: String, onProgress: ((Float) -> Unit)? = null, onComplete: () -> Unit = {}) { |
|
|
|
fun playVoiceFile(filePath: String, onProgress: ((Float) -> Unit)? = null, onComplete: () -> Unit = {}) { |
|
|
|
playFromPosition(filePath, 0, onProgress, onComplete) |
|
|
|
playFromPosition(filePath, 0, onProgress, onComplete) |
|
|
|
@ -193,7 +192,7 @@ class AudioRecorderManager { |
|
|
|
|
|
|
|
|
|
|
|
fun playFromPosition(filePath: String, startMs: Int, onProgress: ((Float) -> Unit)? = null, onComplete: () -> Unit = {}) { |
|
|
|
fun playFromPosition(filePath: String, startMs: Int, onProgress: ((Float) -> Unit)? = null, onComplete: () -> Unit = {}) { |
|
|
|
stopPlayback() |
|
|
|
stopPlayback() |
|
|
|
isPaused = false; elapsedMs = startMs; playing = true; currentPlayPath = filePath |
|
|
|
isPaused = false; elapsedMs = startMs; playing = true |
|
|
|
|
|
|
|
|
|
|
|
playThread = Thread { |
|
|
|
playThread = Thread { |
|
|
|
try { |
|
|
|
try { |
|
|
|
@ -246,7 +245,7 @@ class AudioRecorderManager { |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
LogManager.addLog("ERROR", "AudioPlayer", "play error: ${e.message}") |
|
|
|
LogManager.addLog("ERROR", "AudioPlayer", "play error: ${e.message}") |
|
|
|
} |
|
|
|
} |
|
|
|
playing = false; isPaused = false; currentPlayPath = null |
|
|
|
playing = false; isPaused = false |
|
|
|
onComplete() |
|
|
|
onComplete() |
|
|
|
}.apply { start() } |
|
|
|
}.apply { start() } |
|
|
|
} |
|
|
|
} |
|
|
|
|