setup a new song after changing playlist
This commit is contained in:
parent
a977991d78
commit
761f1a60d4
3 changed files with 11 additions and 4 deletions
|
@ -5,10 +5,10 @@ import android.content.Intent
|
|||
import android.util.TypedValue
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.databases.SongsDatabase
|
||||
import com.simplemobiletools.musicplayer.helpers.CALL_SETUP_AFTER
|
||||
import com.simplemobiletools.musicplayer.helpers.Config
|
||||
import com.simplemobiletools.musicplayer.helpers.PAUSE
|
||||
import com.simplemobiletools.musicplayer.helpers.REFRESH_LIST
|
||||
import com.simplemobiletools.musicplayer.helpers.SETUP
|
||||
import com.simplemobiletools.musicplayer.interfaces.PlaylistsDao
|
||||
import com.simplemobiletools.musicplayer.interfaces.SongsDao
|
||||
import com.simplemobiletools.musicplayer.models.Playlist
|
||||
|
@ -37,9 +37,10 @@ val Context.songsDAO: SongsDao get() = songsDB.SongsDao()
|
|||
fun Context.playlistChanged(newID: Int, callSetup: Boolean = true) {
|
||||
config.currentPlaylist = newID
|
||||
sendIntent(PAUSE)
|
||||
sendIntent(REFRESH_LIST)
|
||||
if (callSetup) {
|
||||
sendIntent(SETUP)
|
||||
Intent(this, MusicService::class.java).apply {
|
||||
putExtra(CALL_SETUP_AFTER, callSetup)
|
||||
action = REFRESH_LIST
|
||||
startService(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simplemobiletools.musicplayer.helpers
|
|||
|
||||
const val SONG_POS = "song_position"
|
||||
const val PROGRESS = "progress"
|
||||
const val CALL_SETUP_AFTER = "call_setup_after"
|
||||
const val EDITED_SONG = "edited_song"
|
||||
const val ALL_SONGS_PLAYLIST_ID = 1
|
||||
|
||||
|
|
|
@ -180,6 +180,11 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
|
|||
Handler(Looper.getMainLooper()).post {
|
||||
mBus!!.post(Events.PlaylistUpdated(mSongs))
|
||||
}
|
||||
|
||||
if (intent.getBooleanExtra(CALL_SETUP_AFTER, false)) {
|
||||
mPlayOnPrepare = false
|
||||
setupNextSong()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
SET_PROGRESS -> {
|
||||
|
|
Loading…
Reference in a new issue