diff --git a/app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt b/app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt index 4f0b441..ce9cf0b 100644 --- a/app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt +++ b/app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt @@ -45,7 +45,6 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import kotlin.random.Random class MainActivity : AppCompatActivity() { enum class ResultCode(val code: Int) { diff --git a/app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt b/app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt index d9f26f5..41d7146 100644 --- a/app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt +++ b/app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt @@ -253,8 +253,6 @@ class PlayerService : Service() { state(false) player.release() - Otter.get().exoCache.release() - stopForeground(true) stopSelf() diff --git a/app/src/main/java/com/github/apognu/otter/playback/QueueManager.kt b/app/src/main/java/com/github/apognu/otter/playback/QueueManager.kt index cf7c47c..96187c3 100644 --- a/app/src/main/java/com/github/apognu/otter/playback/QueueManager.kt +++ b/app/src/main/java/com/github/apognu/otter/playback/QueueManager.kt @@ -127,8 +127,24 @@ class QueueManager(val context: Context) { fun remove(track: Track) { metadata.indexOf(track).let { + if (it < 0) { + return + } + datasources.removeMediaSource(it) metadata.removeAt(it) + + if (it == current) { + CommandBus.send(Command.NextTrack) + } + + if (it < current) { + current-- + } + } + + if (metadata.isEmpty()) { + current = -1 } persist()