cleanup: remove dead currentPlayPath, fix seekVoice _currentPlayingPath reset
- AudioRecorderManager: removed unused currentPlayPath (duplicate of ViewModel state) - ChatViewModel: seekVoice now resets _currentPlayingPath on complete (prevents pause-on-already-ended after seek finishes)
This commit is contained in:
1 parent
2e8aa89397
commit
2edd9bcc06
2 files changed
+3
-4
No files matched your search
@@ -185,7 +185,6 @@ class AudioRecorderManager {
|
||||
@Volatile var elapsedMs: Int = 0; private set
|
||||
var pausedElapsedMs: Int = 0; private set
|
||||
private var playThread: Thread? = null
|
||||
private var currentPlayPath: String? = null
|
||||
|
||||
fun playVoiceFile(filePath: String, onProgress: ((Float) -> Unit)? = null, onComplete: () -> Unit = {}) {
|
||||
playFromPosition(filePath, 0, onProgress, onComplete)
|
||||
@@ -193,7 +192,7 @@ class AudioRecorderManager {
|
||||
|
||||
fun playFromPosition(filePath: String, startMs: Int, onProgress: ((Float) -> Unit)? = null, onComplete: () -> Unit = {}) {
|
||||
stopPlayback()
|
||||
isPaused = false; elapsedMs = startMs; playing = true; currentPlayPath = filePath
|
||||
isPaused = false; elapsedMs = startMs; playing = true
|
||||
|
||||
playThread = Thread {
|
||||
try {
|
||||
@@ -246,7 +245,7 @@ class AudioRecorderManager {
|
||||
} catch (e: Exception) {
|
||||
LogManager.addLog("ERROR", "AudioPlayer", "play error: ${e.message}")
|
||||
}
|
||||
playing = false; isPaused = false; currentPlayPath = null
|
||||
playing = false; isPaused = false
|
||||
onComplete()
|
||||
}.apply { start() }
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ class ChatViewModel : ViewModel() {
|
||||
fun seekVoice(filePath: String, seekMs: Int, onDone: () -> Unit) {
|
||||
audioRecorder.stopPlayback()
|
||||
_currentPlayingPath = filePath
|
||||
audioRecorder.playFromPosition(filePath, seekMs, onComplete = onDone)
|
||||
audioRecorder.playFromPosition(filePath, seekMs, onComplete = { _currentPlayingPath = null; onDone() })
|
||||
}
|
||||
|
||||
fun clearState() {
|
||||
|
||||
Reference in new issue
Block a user