Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d5a97cdac | ||
|
|
8e737fae2e |
No files matched your search
@@ -208,7 +208,7 @@ Tagged builds (`v*`) publish to internal testing from CI. The Gitea secrets are:
|
|||||||
| `ANDROID_KEY_PASSWORD` | key password |
|
| `ANDROID_KEY_PASSWORD` | key password |
|
||||||
| `PLAY_SERVICE_ACCOUNT_JSON` | contents of the service account JSON |
|
| `PLAY_SERVICE_ACCOUNT_JSON` | contents of the service account JSON |
|
||||||
|
|
||||||
Then `git tag v0.4.0 && git push --tags` builds, signs and uploads the bundle.
|
Then `git tag v0.4.2 && git push --tags` builds, signs and uploads the bundle.
|
||||||
Gradle Play Publisher asks Play for the next free `versionCode`
|
Gradle Play Publisher asks Play for the next free `versionCode`
|
||||||
(`ResolutionStrategy.AUTO`), so only the tag/version name needs to change.
|
(`ResolutionStrategy.AUTO`), so only the tag/version name needs to change.
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ val hasUploadKey = uploadKeyStore?.exists() == true &&
|
|||||||
val appVersionCode = (System.getenv("VERSION_CODE") ?: localProperties.getProperty("VERSION_CODE") ?: "1").toInt()
|
val appVersionCode = (System.getenv("VERSION_CODE") ?: localProperties.getProperty("VERSION_CODE") ?: "1").toInt()
|
||||||
val appVersionName = System.getenv("VERSION_NAME")
|
val appVersionName = System.getenv("VERSION_NAME")
|
||||||
?: localProperties.getProperty("VERSION_NAME")
|
?: localProperties.getProperty("VERSION_NAME")
|
||||||
?: "0.4.0"
|
?: "0.4.2"
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
androidTarget {
|
androidTarget {
|
||||||
|
|||||||
+4
-1
@@ -184,7 +184,10 @@ class MediaControllerAudioPlayer(context: Context) : AudioPlayer {
|
|||||||
Bundle().apply { putDouble(GAIN_DB_KEY, track.gainDb ?: 0.0) },
|
Bundle().apply { putDouble(GAIN_DB_KEY, track.gainDb ?: 0.0) },
|
||||||
)
|
)
|
||||||
.apply {
|
.apply {
|
||||||
if (!track.artworkUri.isNullOrBlank()) {
|
val bytes = track.artworkBytes
|
||||||
|
if (bytes != null && bytes.isNotEmpty()) {
|
||||||
|
setArtworkData(bytes, MediaMetadata.PICTURE_TYPE_FRONT_COVER)
|
||||||
|
} else if (!track.artworkUri.isNullOrBlank()) {
|
||||||
setArtworkUri(Uri.parse(track.artworkUri))
|
setArtworkUri(Uri.parse(track.artworkUri))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -12,6 +12,8 @@ data class PlaybackTrack(
|
|||||||
val source: String,
|
val source: String,
|
||||||
val local: Boolean,
|
val local: Boolean,
|
||||||
val artworkUri: String? = null,
|
val artworkUri: String? = null,
|
||||||
|
/** Cached cover for offline playback; avoids a network fetch in the notification. */
|
||||||
|
val artworkBytes: ByteArray? = null,
|
||||||
/** Server-measured gain; null leaves the track untouched. */
|
/** Server-measured gain; null leaves the track untouched. */
|
||||||
val gainDb: Double? = null,
|
val gainDb: Double? = null,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -159,6 +159,33 @@ class AppStore(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The media service can outlive the UI (for example after the task
|
||||||
|
// is swiped). If it still owns a timeline, mirror it instead of
|
||||||
|
// showing the last persisted position as paused.
|
||||||
|
scope.launch {
|
||||||
|
repeat(20) {
|
||||||
|
kotlinx.coroutines.delay(250)
|
||||||
|
if (player.queueSize() > 0) {
|
||||||
|
if (timelineSongs.isNotEmpty()) {
|
||||||
|
playbackStarted = true
|
||||||
|
trackIndex = player.currentIndex().coerceIn(timelineSongs.indices)
|
||||||
|
applyTimelineState()
|
||||||
|
_state.update {
|
||||||
|
it.copy(
|
||||||
|
playing = player.isPlaying(),
|
||||||
|
positionSeconds = player.positionSeconds().coerceAtLeast(0.0),
|
||||||
|
durationSeconds = player.durationSeconds()
|
||||||
|
.takeIf { value -> value > 0 }
|
||||||
|
?: it.durationSeconds,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
startPolling()
|
||||||
|
}
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (session == null) return@launch
|
if (session == null) return@launch
|
||||||
|
|
||||||
api.restore(session.serverUrl, session.token)
|
api.restore(session.serverUrl, session.token)
|
||||||
@@ -984,15 +1011,15 @@ class AppStore(
|
|||||||
fun setSleepAfterTrack() {
|
fun setSleepAfterTrack() {
|
||||||
val state = _state.value
|
val state = _state.value
|
||||||
if (state.current == null) return
|
if (state.current == null) return
|
||||||
val remaining = (state.durationSeconds - state.positionSeconds)
|
val remaining = (state.durationSeconds - state.positionSeconds).coerceAtLeast(0.0)
|
||||||
.coerceAtLeast(0.0)
|
if (remaining <= 0.0) {
|
||||||
.let { kotlin.math.ceil(it).toLong() }
|
|
||||||
if (remaining <= 0) {
|
|
||||||
player.pause()
|
player.pause()
|
||||||
_state.update { it.copy(playing = false) }
|
_state.update { it.copy(playing = false) }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setSleepCountdown(remaining, atTrackEnd = true)
|
// Stop slightly before the boundary so ExoPlayer cannot start the next
|
||||||
|
// item in the sub-second gap before the timer reaches the service.
|
||||||
|
setSleepCountdown((remaining - 0.5).toLong().coerceAtLeast(1L), atTrackEnd = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setSleepCountdown(seconds: Long?, atTrackEnd: Boolean) {
|
private fun setSleepCountdown(seconds: Long?, atTrackEnd: Boolean) {
|
||||||
@@ -1368,6 +1395,7 @@ class AppStore(
|
|||||||
source = local ?: api.streamUrl(song.id),
|
source = local ?: api.streamUrl(song.id),
|
||||||
local = local != null,
|
local = local != null,
|
||||||
artworkUri = api.coverUrl(song.id),
|
artworkUri = api.coverUrl(song.id),
|
||||||
|
artworkBytes = storage.artworkBytes(song.id),
|
||||||
gainDb = if (_state.value.normalizationEnabled) song.gainDb else null,
|
gainDb = if (_state.value.normalizationEnabled) song.gainDb else null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1515,15 +1543,9 @@ class AppStore(
|
|||||||
delay(500)
|
delay(500)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// A prefetch may already have appended the next batch while ExoPlayer
|
// "Finish this track" must win over an already-prefetched next batch.
|
||||||
// was finishing. Play it instead of requesting duplicates.
|
|
||||||
if (trackIndex + 1 < timelineSongs.size) {
|
|
||||||
report("completed", timelineSongs.getOrNull(trackIndex)?.id, _state.value.positionSeconds.toInt())
|
|
||||||
suppressCompletion = true
|
|
||||||
player.playIndex(trackIndex + 1)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (_state.value.sleepAtTrackEnd) {
|
if (_state.value.sleepAtTrackEnd) {
|
||||||
|
report("completed", timelineSongs.getOrNull(trackIndex)?.id, _state.value.positionSeconds.toInt())
|
||||||
sleepJob?.cancel()
|
sleepJob?.cancel()
|
||||||
sleepJob = null
|
sleepJob = null
|
||||||
player.scheduleSleepTimer(null)
|
player.scheduleSleepTimer(null)
|
||||||
@@ -1537,8 +1559,15 @@ class AppStore(
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// A prefetch may already have appended the next batch while ExoPlayer
|
||||||
|
// was finishing. Play it instead of requesting duplicates.
|
||||||
|
if (trackIndex + 1 < timelineSongs.size) {
|
||||||
|
report("completed", timelineSongs.getOrNull(trackIndex)?.id, _state.value.positionSeconds.toInt())
|
||||||
|
suppressCompletion = true
|
||||||
|
player.playIndex(trackIndex + 1)
|
||||||
|
return true
|
||||||
|
}
|
||||||
val session = _state.value.session
|
val session = _state.value.session
|
||||||
val current = timelineSongs.getOrNull(trackIndex)
|
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
report("completed", timelineSongs.getOrNull(trackIndex)?.id, _state.value.positionSeconds.toInt())
|
report("completed", timelineSongs.getOrNull(trackIndex)?.id, _state.value.positionSeconds.toInt())
|
||||||
_state.update { it.copy(playing = false) }
|
_state.update { it.copy(playing = false) }
|
||||||
|
|||||||
+7
-1
@@ -72,6 +72,7 @@ fun MoodSettingsScreen(state: AppState, store: AppStore) {
|
|||||||
var hours by remember(mood.id) { mutableStateOf(mood.refreshHours.toString()) }
|
var hours by remember(mood.id) { mutableStateOf(mood.refreshHours.toString()) }
|
||||||
var confirmDelete by remember { mutableStateOf(false) }
|
var confirmDelete by remember { mutableStateOf(false) }
|
||||||
val offline = mood.id in state.offlineMoods
|
val offline = mood.id in state.offlineMoods
|
||||||
|
val offlineDownloaded = detail.songs.count { it.song.id in state.downloads }
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
@@ -200,7 +201,12 @@ fun MoodSettingsScreen(state: AppState, store: AppStore) {
|
|||||||
Text("Keep this mood offline", style = MaterialTheme.typography.bodyMedium)
|
Text("Keep this mood offline", style = MaterialTheme.typography.bodyMedium)
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
"Downloads every song and keeps new additions in sync on Wi-Fi.",
|
if (offline) {
|
||||||
|
"$offlineDownloaded of ${detail.songs.size} downloaded · " +
|
||||||
|
"new songs sync on Wi-Fi"
|
||||||
|
} else {
|
||||||
|
"Downloads every song and keeps new additions in sync on Wi-Fi."
|
||||||
|
},
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -193,7 +193,7 @@ fun SettingsScreen(state: AppState, store: AppStore) {
|
|||||||
Column(Modifier.padding(18.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
Column(Modifier.padding(18.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||||
Text("About", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
|
Text("About", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
|
||||||
Text(
|
Text(
|
||||||
"AudioManager 0.4.0 · $platformName",
|
"AudioManager 0.4.2 · $platformName",
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -480,6 +480,34 @@ class AppStoreTest {
|
|||||||
store.release()
|
store.release()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `finish this track does not start the prefetched next song`() = runTest {
|
||||||
|
val storage = MemoryStorage()
|
||||||
|
val cache = AppCache(storage)
|
||||||
|
cache.saveSession(SessionState("http://music", "token", User("alice", admin = false)))
|
||||||
|
cache.savePlayback(
|
||||||
|
PlaybackSnapshot(
|
||||||
|
current = song("a", duration = 180),
|
||||||
|
queue = listOf(song("b", duration = 180)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
val player = FakePlayer()
|
||||||
|
val store = store(storage, cache, player)
|
||||||
|
runCurrent()
|
||||||
|
store.togglePlayPause()
|
||||||
|
awaitState { store.state.value.playing }
|
||||||
|
|
||||||
|
store.setSleepAfterTrack()
|
||||||
|
player.finish()
|
||||||
|
advanceTimeBy(600)
|
||||||
|
runCurrent()
|
||||||
|
|
||||||
|
assertFalse(store.state.value.playing)
|
||||||
|
assertEquals("a", store.state.value.current?.id)
|
||||||
|
assertEquals(listOf("b"), store.state.value.queue.map { it.id })
|
||||||
|
store.release()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `logout clears the session and the mood cache`() = runTest {
|
fun `logout clears the session and the mood cache`() = runTest {
|
||||||
val storage = MemoryStorage()
|
val storage = MemoryStorage()
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ class DesktopAudioPlayer : AudioPlayer {
|
|||||||
val track = tracks.getOrNull(index) ?: return
|
val track = tracks.getOrNull(index) ?: return
|
||||||
this.index = index
|
this.index = index
|
||||||
currentTrack = track
|
currentTrack = track
|
||||||
gain = track.gainDb?.let { 10.0.pow(it / 20.0).toFloat() }?.coerceIn(0f, 2f) ?: 1f
|
gain = track.gainDb?.let { 10.0.pow(it / 20.0).toFloat() }?.coerceIn(0f, 4f) ?: 1f
|
||||||
start(track, startAtSeconds)
|
start(track, startAtSeconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user