@ -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) {
@ -253,8 +253,6 @@ class PlayerService : Service() {
state(false)
player.release()
Otter.get().exoCache.release()
stopForeground(true)
stopSelf()
@ -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()