1
0
mirror of https://github.com/apognu/otter synced 2024-12-12 15:16:04 +01:00

Prevent issue on queue item deletion. Should close #48.

This commit is contained in:
Antoine POPINEAU 2020-06-20 16:32:14 +02:00
parent e539cc26dd
commit 66c7915307
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
3 changed files with 16 additions and 3 deletions

View File

@ -45,7 +45,6 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlin.random.Random
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
enum class ResultCode(val code: Int) { enum class ResultCode(val code: Int) {

View File

@ -253,8 +253,6 @@ class PlayerService : Service() {
state(false) state(false)
player.release() player.release()
Otter.get().exoCache.release()
stopForeground(true) stopForeground(true)
stopSelf() stopSelf()

View File

@ -127,8 +127,24 @@ class QueueManager(val context: Context) {
fun remove(track: Track) { fun remove(track: Track) {
metadata.indexOf(track).let { metadata.indexOf(track).let {
if (it < 0) {
return
}
datasources.removeMediaSource(it) datasources.removeMediaSource(it)
metadata.removeAt(it) metadata.removeAt(it)
if (it == current) {
CommandBus.send(Command.NextTrack)
}
if (it < current) {
current--
}
}
if (metadata.isEmpty()) {
current = -1
} }
persist() persist()