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:
parent
e539cc26dd
commit
66c7915307
@ -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) {
|
||||||
|
@ -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()
|
||||||
|
|
||||||
|
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user