fix(ringtones): let a sound preview be stopped
The picker's play button only ever started a preview; nothing but taking a row, playing another one or leaving the picker stopped it. The previewer now publishes what it is sounding, cleared on stop and when the tone ends, and the playing row's button becomes a stop button.
This commit is contained in:
1 parent
fe64521707
commit
face2edb8d
11 files changed
+59
-3
No files matched your search
@@ -4,6 +4,7 @@ import de.jeanlucmakiola.clockula.data.ringtones.RingtoneCatalog
|
||||
import de.jeanlucmakiola.clockula.data.ringtones.RingtonePreviewer
|
||||
import de.jeanlucmakiola.clockula.domain.RingtoneOption
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
/**
|
||||
* The device's sound catalog, scripted: which tones it has, what it can name,
|
||||
@@ -68,11 +69,15 @@ class FakeRingtonePreviewer : RingtonePreviewer {
|
||||
|
||||
val events: MutableList<PreviewEvent> = mutableListOf()
|
||||
|
||||
override val playing = MutableStateFlow<String?>(null)
|
||||
|
||||
override suspend fun play(uri: String) {
|
||||
events += PreviewEvent.Played(uri)
|
||||
playing.value = uri
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
events += PreviewEvent.Stopped
|
||||
playing.value = null
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user