mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-14 18:50:51 +01:00
Make public playlist immutable (only Downloader can touch it)
Remove external usage of playlist_revision
This commit is contained in:
parent
69825b28bb
commit
8830d76497
@ -220,6 +220,6 @@ class DownloadListModel(application: Application) : GenericListModel(application
|
|||||||
private val downloader by inject<Downloader>()
|
private val downloader by inject<Downloader>()
|
||||||
|
|
||||||
fun getList(): LiveData<List<DownloadFile>> {
|
fun getList(): LiveData<List<DownloadFile>> {
|
||||||
return downloader.observableList
|
return downloader.observableDownloads
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import android.widget.TextView
|
|||||||
import android.widget.ViewFlipper
|
import android.widget.ViewFlipper
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
import com.mobeta.android.dslv.DragSortListView
|
import com.mobeta.android.dslv.DragSortListView
|
||||||
import com.mobeta.android.dslv.DragSortListView.DragSortListener
|
import com.mobeta.android.dslv.DragSortListView.DragSortListener
|
||||||
@ -49,6 +50,7 @@ import java.util.concurrent.ScheduledExecutorService
|
|||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
import org.koin.core.component.KoinComponent
|
import org.koin.core.component.KoinComponent
|
||||||
import org.koin.core.component.get
|
import org.koin.core.component.get
|
||||||
@ -66,6 +68,7 @@ import org.moire.ultrasonic.service.DownloadFile
|
|||||||
import org.moire.ultrasonic.service.LocalMediaPlayer
|
import org.moire.ultrasonic.service.LocalMediaPlayer
|
||||||
import org.moire.ultrasonic.service.MediaPlayerController
|
import org.moire.ultrasonic.service.MediaPlayerController
|
||||||
import org.moire.ultrasonic.service.MusicServiceFactory.getMusicService
|
import org.moire.ultrasonic.service.MusicServiceFactory.getMusicService
|
||||||
|
import org.moire.ultrasonic.service.RxBus
|
||||||
import org.moire.ultrasonic.subsonic.ImageLoaderProvider
|
import org.moire.ultrasonic.subsonic.ImageLoaderProvider
|
||||||
import org.moire.ultrasonic.subsonic.NetworkAndStorageChecker
|
import org.moire.ultrasonic.subsonic.NetworkAndStorageChecker
|
||||||
import org.moire.ultrasonic.subsonic.ShareHandler
|
import org.moire.ultrasonic.subsonic.ShareHandler
|
||||||
@ -88,8 +91,6 @@ import timber.log.Timber
|
|||||||
*/
|
*/
|
||||||
@Suppress("LargeClass", "TooManyFunctions", "MagicNumber")
|
@Suppress("LargeClass", "TooManyFunctions", "MagicNumber")
|
||||||
class PlayerFragment : Fragment(), GestureDetector.OnGestureListener, KoinComponent {
|
class PlayerFragment : Fragment(), GestureDetector.OnGestureListener, KoinComponent {
|
||||||
// Settings
|
|
||||||
private var currentRevision: Long = 0
|
|
||||||
private var swipeDistance = 0
|
private var swipeDistance = 0
|
||||||
private var swipeVelocity = 0
|
private var swipeVelocity = 0
|
||||||
private var jukeboxAvailable = false
|
private var jukeboxAvailable = false
|
||||||
@ -419,13 +420,21 @@ class PlayerFragment : Fragment(), GestureDetector.OnGestureListener, KoinCompon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
Thread {
|
|
||||||
|
// Observe playlist changes and update the UI
|
||||||
|
RxBus.playlistObservable.subscribe {
|
||||||
|
onPlaylistChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query the Jukebox state off-thread
|
||||||
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
try {
|
try {
|
||||||
jukeboxAvailable = mediaPlayerController.isJukeboxAvailable
|
jukeboxAvailable = mediaPlayerController.isJukeboxAvailable
|
||||||
} catch (all: Exception) {
|
} catch (all: Exception) {
|
||||||
Timber.e(all)
|
Timber.e(all)
|
||||||
}
|
}
|
||||||
}.start()
|
}
|
||||||
|
|
||||||
view.setOnTouchListener { _, event -> gestureScanner.onTouchEvent(event) }
|
view.setOnTouchListener { _, event -> gestureScanner.onTouchEvent(event) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,9 +806,6 @@ class PlayerFragment : Fragment(), GestureDetector.OnGestureListener, KoinCompon
|
|||||||
private fun update(cancel: CancellationToken?) {
|
private fun update(cancel: CancellationToken?) {
|
||||||
if (cancel!!.isCancellationRequested) return
|
if (cancel!!.isCancellationRequested) return
|
||||||
val mediaPlayerController = mediaPlayerController
|
val mediaPlayerController = mediaPlayerController
|
||||||
if (currentRevision != mediaPlayerController.playListUpdateRevision) {
|
|
||||||
onPlaylistChanged()
|
|
||||||
}
|
|
||||||
if (currentPlaying != mediaPlayerController.currentPlaying) {
|
if (currentPlaying != mediaPlayerController.currentPlaying) {
|
||||||
onCurrentChanged()
|
onCurrentChanged()
|
||||||
}
|
}
|
||||||
@ -914,7 +920,6 @@ class PlayerFragment : Fragment(), GestureDetector.OnGestureListener, KoinCompon
|
|||||||
|
|
||||||
emptyTextView.isVisible = list.isEmpty()
|
emptyTextView.isVisible = list.isEmpty()
|
||||||
|
|
||||||
currentRevision = mediaPlayerController.playListUpdateRevision
|
|
||||||
when (mediaPlayerController.repeatMode) {
|
when (mediaPlayerController.repeatMode) {
|
||||||
RepeatMode.OFF -> repeatButton.setImageDrawable(
|
RepeatMode.OFF -> repeatButton.setImageDrawable(
|
||||||
Util.getDrawableFromAttribute(
|
Util.getDrawableFromAttribute(
|
||||||
|
@ -30,14 +30,15 @@ class Downloader(
|
|||||||
private val externalStorageMonitor: ExternalStorageMonitor,
|
private val externalStorageMonitor: ExternalStorageMonitor,
|
||||||
private val localMediaPlayer: LocalMediaPlayer
|
private val localMediaPlayer: LocalMediaPlayer
|
||||||
) : KoinComponent {
|
) : KoinComponent {
|
||||||
val playlist: MutableList<DownloadFile> = ArrayList()
|
|
||||||
|
private val playlist = mutableListOf<DownloadFile>()
|
||||||
|
|
||||||
var started: Boolean = false
|
var started: Boolean = false
|
||||||
|
|
||||||
private val downloadQueue: PriorityQueue<DownloadFile> = PriorityQueue<DownloadFile>()
|
private val downloadQueue = PriorityQueue<DownloadFile>()
|
||||||
private val activelyDownloading: MutableList<DownloadFile> = ArrayList()
|
private val activelyDownloading = mutableListOf<DownloadFile>()
|
||||||
|
|
||||||
val observableList: MutableLiveData<List<DownloadFile>> = MutableLiveData<List<DownloadFile>>()
|
val observableDownloads = MutableLiveData<List<DownloadFile>>()
|
||||||
|
|
||||||
private val jukeboxMediaPlayer: JukeboxMediaPlayer by inject()
|
private val jukeboxMediaPlayer: JukeboxMediaPlayer by inject()
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ class Downloader(
|
|||||||
private var executorService: ScheduledExecutorService? = null
|
private var executorService: ScheduledExecutorService? = null
|
||||||
private var wifiLock: WifiManager.WifiLock? = null
|
private var wifiLock: WifiManager.WifiLock? = null
|
||||||
|
|
||||||
var playlistUpdateRevision: Long = 0
|
private var playlistUpdateRevision: Long = 0
|
||||||
private set(value) {
|
private set(value) {
|
||||||
field = value
|
field = value
|
||||||
RxBus.playlistPublisher.onNext(playlist)
|
RxBus.playlistPublisher.onNext(playlist)
|
||||||
@ -65,7 +66,7 @@ class Downloader(
|
|||||||
stop()
|
stop()
|
||||||
clearPlaylist()
|
clearPlaylist()
|
||||||
clearBackground()
|
clearBackground()
|
||||||
observableList.value = listOf()
|
observableDownloads.value = listOf()
|
||||||
Timber.i("Downloader destroyed")
|
Timber.i("Downloader destroyed")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +184,7 @@ class Downloader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateLiveData() {
|
private fun updateLiveData() {
|
||||||
observableList.postValue(downloads)
|
observableDownloads.postValue(downloads)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startDownloadOnService(task: DownloadFile) {
|
private fun startDownloadOnService(task: DownloadFile) {
|
||||||
@ -268,6 +269,10 @@ class Downloader(
|
|||||||
return temp.distinct().sorted()
|
return temp.distinct().sorted()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Public facing playlist (immutable)
|
||||||
|
@Synchronized
|
||||||
|
fun getPlaylist(): List<DownloadFile> = playlist
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun clearPlaylist() {
|
fun clearPlaylist() {
|
||||||
playlist.clear()
|
playlist.clear()
|
||||||
|
@ -180,7 +180,7 @@ class MediaPlayerController(
|
|||||||
downloader.addToPlaylist(filteredSongs, save, autoPlay, playNext, newPlaylist)
|
downloader.addToPlaylist(filteredSongs, save, autoPlay, playNext, newPlaylist)
|
||||||
jukeboxMediaPlayer.updatePlaylist()
|
jukeboxMediaPlayer.updatePlaylist()
|
||||||
if (shuffle) shuffle()
|
if (shuffle) shuffle()
|
||||||
val isLastTrack = (downloader.playlist.size - 1 == downloader.currentPlayingIndex)
|
val isLastTrack = (downloader.getPlaylist().size - 1 == downloader.currentPlayingIndex)
|
||||||
|
|
||||||
if (!playNext && !autoPlay && isLastTrack) {
|
if (!playNext && !autoPlay && isLastTrack) {
|
||||||
val mediaPlayerService = runningInstance
|
val mediaPlayerService = runningInstance
|
||||||
@ -190,15 +190,15 @@ class MediaPlayerController(
|
|||||||
if (autoPlay) {
|
if (autoPlay) {
|
||||||
play(0)
|
play(0)
|
||||||
} else {
|
} else {
|
||||||
if (localMediaPlayer.currentPlaying == null && downloader.playlist.size > 0) {
|
if (localMediaPlayer.currentPlaying == null && downloader.getPlaylist().isNotEmpty()) {
|
||||||
localMediaPlayer.currentPlaying = downloader.playlist[0]
|
localMediaPlayer.currentPlaying = downloader.getPlaylist()[0]
|
||||||
downloader.playlist[0].setPlaying(true)
|
downloader.getPlaylist()[0].setPlaying(true)
|
||||||
}
|
}
|
||||||
downloader.checkDownloads()
|
downloader.checkDownloads()
|
||||||
}
|
}
|
||||||
|
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex,
|
downloader.currentPlayingIndex,
|
||||||
playerPosition
|
playerPosition
|
||||||
)
|
)
|
||||||
@ -210,7 +210,7 @@ class MediaPlayerController(
|
|||||||
val filteredSongs = songs.filterNotNull()
|
val filteredSongs = songs.filterNotNull()
|
||||||
downloader.downloadBackground(filteredSongs, save)
|
downloader.downloadBackground(filteredSongs, save)
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex,
|
downloader.currentPlayingIndex,
|
||||||
playerPosition
|
playerPosition
|
||||||
)
|
)
|
||||||
@ -241,7 +241,7 @@ class MediaPlayerController(
|
|||||||
fun shuffle() {
|
fun shuffle() {
|
||||||
downloader.shuffle()
|
downloader.shuffle()
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex,
|
downloader.currentPlayingIndex,
|
||||||
playerPosition
|
playerPosition
|
||||||
)
|
)
|
||||||
@ -270,7 +270,7 @@ class MediaPlayerController(
|
|||||||
downloader.clearPlaylist()
|
downloader.clearPlaylist()
|
||||||
if (serialize) {
|
if (serialize) {
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex, playerPosition
|
downloader.currentPlayingIndex, playerPosition
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -281,16 +281,11 @@ class MediaPlayerController(
|
|||||||
@Synchronized
|
@Synchronized
|
||||||
fun clearIncomplete() {
|
fun clearIncomplete() {
|
||||||
reset()
|
reset()
|
||||||
val iterator = downloader.playlist.iterator()
|
|
||||||
while (iterator.hasNext()) {
|
downloader.clearIncomplete()
|
||||||
val downloadFile = iterator.next()
|
|
||||||
if (!downloadFile.isCompleteFileAvailable) {
|
|
||||||
iterator.remove()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex,
|
downloader.currentPlayingIndex,
|
||||||
playerPosition
|
playerPosition
|
||||||
)
|
)
|
||||||
@ -307,7 +302,7 @@ class MediaPlayerController(
|
|||||||
downloader.removeFromPlaylist(downloadFile)
|
downloader.removeFromPlaylist(downloadFile)
|
||||||
|
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex,
|
downloader.currentPlayingIndex,
|
||||||
playerPosition
|
playerPosition
|
||||||
)
|
)
|
||||||
@ -359,12 +354,12 @@ class MediaPlayerController(
|
|||||||
when (repeatMode) {
|
when (repeatMode) {
|
||||||
RepeatMode.SINGLE, RepeatMode.OFF -> {
|
RepeatMode.SINGLE, RepeatMode.OFF -> {
|
||||||
// Play next if exists
|
// Play next if exists
|
||||||
if (index + 1 >= 0 && index + 1 < downloader.playlist.size) {
|
if (index + 1 >= 0 && index + 1 < downloader.getPlaylist().size) {
|
||||||
play(index + 1)
|
play(index + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RepeatMode.ALL -> {
|
RepeatMode.ALL -> {
|
||||||
play((index + 1) % downloader.playlist.size)
|
play((index + 1) % downloader.getPlaylist().size)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
}
|
}
|
||||||
@ -492,16 +487,13 @@ class MediaPlayerController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val playlistSize: Int
|
val playlistSize: Int
|
||||||
get() = downloader.playlist.size
|
get() = downloader.getPlaylist().size
|
||||||
|
|
||||||
val currentPlayingNumberOnPlaylist: Int
|
val currentPlayingNumberOnPlaylist: Int
|
||||||
get() = downloader.currentPlayingIndex
|
get() = downloader.currentPlayingIndex
|
||||||
|
|
||||||
val playList: List<DownloadFile>
|
val playList: List<DownloadFile>
|
||||||
get() = downloader.playlist
|
get() = downloader.getPlaylist()
|
||||||
|
|
||||||
val playListUpdateRevision: Long
|
|
||||||
get() = downloader.playlistUpdateRevision
|
|
||||||
|
|
||||||
val playListDuration: Long
|
val playListDuration: Long
|
||||||
get() = downloader.downloadListDuration
|
get() = downloader.downloadListDuration
|
||||||
|
@ -70,7 +70,7 @@ class MediaPlayerLifecycleSupport : KoinComponent {
|
|||||||
// Work-around: Serialize again, as the restore() method creates a
|
// Work-around: Serialize again, as the restore() method creates a
|
||||||
// serialization without current playing info.
|
// serialization without current playing info.
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex,
|
downloader.currentPlayingIndex,
|
||||||
mediaPlayerController.playerPosition
|
mediaPlayerController.playerPosition
|
||||||
)
|
)
|
||||||
@ -87,7 +87,7 @@ class MediaPlayerLifecycleSupport : KoinComponent {
|
|||||||
if (!created) return
|
if (!created) return
|
||||||
|
|
||||||
playbackStateSerializer.serializeNow(
|
playbackStateSerializer.serializeNow(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex,
|
downloader.currentPlayingIndex,
|
||||||
mediaPlayerController.playerPosition
|
mediaPlayerController.playerPosition
|
||||||
)
|
)
|
||||||
|
@ -87,7 +87,7 @@ class MediaPlayerService : Service() {
|
|||||||
|
|
||||||
localMediaPlayer.onPrepared = {
|
localMediaPlayer.onPrepared = {
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex,
|
downloader.currentPlayingIndex,
|
||||||
playerPosition
|
playerPosition
|
||||||
)
|
)
|
||||||
@ -198,7 +198,7 @@ class MediaPlayerService : Service() {
|
|||||||
@Synchronized
|
@Synchronized
|
||||||
fun setCurrentPlaying(currentPlayingIndex: Int) {
|
fun setCurrentPlaying(currentPlayingIndex: Int) {
|
||||||
try {
|
try {
|
||||||
localMediaPlayer.setCurrentPlaying(downloader.playlist[currentPlayingIndex])
|
localMediaPlayer.setCurrentPlaying(downloader.getPlaylist()[currentPlayingIndex])
|
||||||
} catch (ignored: IndexOutOfBoundsException) {
|
} catch (ignored: IndexOutOfBoundsException) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ class MediaPlayerService : Service() {
|
|||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
when (Settings.repeatMode) {
|
when (Settings.repeatMode) {
|
||||||
RepeatMode.OFF -> index += 1
|
RepeatMode.OFF -> index += 1
|
||||||
RepeatMode.ALL -> index = (index + 1) % downloader.playlist.size
|
RepeatMode.ALL -> index = (index + 1) % downloader.getPlaylist().size
|
||||||
RepeatMode.SINGLE -> {
|
RepeatMode.SINGLE -> {
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
@ -224,8 +224,8 @@ class MediaPlayerService : Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
localMediaPlayer.clearNextPlaying(false)
|
localMediaPlayer.clearNextPlaying(false)
|
||||||
if (index < downloader.playlist.size && index != -1) {
|
if (index < downloader.getPlaylist().size && index != -1) {
|
||||||
localMediaPlayer.setNextPlaying(downloader.playlist[index])
|
localMediaPlayer.setNextPlaying(downloader.getPlaylist()[index])
|
||||||
} else {
|
} else {
|
||||||
localMediaPlayer.clearNextPlaying(true)
|
localMediaPlayer.clearNextPlaying(true)
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ class MediaPlayerService : Service() {
|
|||||||
@Synchronized
|
@Synchronized
|
||||||
fun play(index: Int, start: Boolean) {
|
fun play(index: Int, start: Boolean) {
|
||||||
Timber.v("play requested for %d", index)
|
Timber.v("play requested for %d", index)
|
||||||
if (index < 0 || index >= downloader.playlist.size) {
|
if (index < 0 || index >= downloader.getPlaylist().size) {
|
||||||
resetPlayback()
|
resetPlayback()
|
||||||
} else {
|
} else {
|
||||||
setCurrentPlaying(index)
|
setCurrentPlaying(index)
|
||||||
@ -286,7 +286,7 @@ class MediaPlayerService : Service() {
|
|||||||
if (jukeboxMediaPlayer.isEnabled) {
|
if (jukeboxMediaPlayer.isEnabled) {
|
||||||
jukeboxMediaPlayer.skip(index, 0)
|
jukeboxMediaPlayer.skip(index, 0)
|
||||||
} else {
|
} else {
|
||||||
localMediaPlayer.play(downloader.playlist[index])
|
localMediaPlayer.play(downloader.getPlaylist()[index])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
downloader.checkDownloads()
|
downloader.checkDownloads()
|
||||||
@ -299,7 +299,7 @@ class MediaPlayerService : Service() {
|
|||||||
localMediaPlayer.reset()
|
localMediaPlayer.reset()
|
||||||
localMediaPlayer.setCurrentPlaying(null)
|
localMediaPlayer.setCurrentPlaying(null)
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex, playerPosition
|
downloader.currentPlayingIndex, playerPosition
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ class MediaPlayerService : Service() {
|
|||||||
when {
|
when {
|
||||||
playerState === PlayerState.PAUSED -> {
|
playerState === PlayerState.PAUSED -> {
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist, downloader.currentPlayingIndex, playerPosition
|
downloader.getPlaylist(), downloader.currentPlayingIndex, playerPosition
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
playerState === PlayerState.STARTED -> {
|
playerState === PlayerState.STARTED -> {
|
||||||
@ -382,8 +382,8 @@ class MediaPlayerService : Service() {
|
|||||||
Util.broadcastPlaybackStatusChange(context, playerState)
|
Util.broadcastPlaybackStatusChange(context, playerState)
|
||||||
Util.broadcastA2dpPlayStatusChange(
|
Util.broadcastA2dpPlayStatusChange(
|
||||||
context, playerState, song,
|
context, playerState, song,
|
||||||
downloader.playlist.size,
|
downloader.getPlaylist().size,
|
||||||
downloader.playlist.indexOf(currentPlaying) + 1, playerPosition
|
downloader.getPlaylist().indexOf(currentPlaying) + 1, playerPosition
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// State didn't change, only the track
|
// State didn't change, only the track
|
||||||
@ -434,7 +434,7 @@ class MediaPlayerService : Service() {
|
|||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
when (Settings.repeatMode) {
|
when (Settings.repeatMode) {
|
||||||
RepeatMode.OFF -> {
|
RepeatMode.OFF -> {
|
||||||
if (index + 1 < 0 || index + 1 >= downloader.playlist.size) {
|
if (index + 1 < 0 || index + 1 >= downloader.getPlaylist().size) {
|
||||||
if (Settings.shouldClearPlaylist) {
|
if (Settings.shouldClearPlaylist) {
|
||||||
clear(true)
|
clear(true)
|
||||||
jukeboxMediaPlayer.updatePlaylist()
|
jukeboxMediaPlayer.updatePlaylist()
|
||||||
@ -445,7 +445,7 @@ class MediaPlayerService : Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
RepeatMode.ALL -> {
|
RepeatMode.ALL -> {
|
||||||
play((index + 1) % downloader.playlist.size)
|
play((index + 1) % downloader.getPlaylist().size)
|
||||||
}
|
}
|
||||||
RepeatMode.SINGLE -> play(index)
|
RepeatMode.SINGLE -> play(index)
|
||||||
else -> {
|
else -> {
|
||||||
@ -464,7 +464,7 @@ class MediaPlayerService : Service() {
|
|||||||
setNextPlaying()
|
setNextPlaying()
|
||||||
if (serialize) {
|
if (serialize) {
|
||||||
playbackStateSerializer.serialize(
|
playbackStateSerializer.serialize(
|
||||||
downloader.playlist,
|
downloader.getPlaylist(),
|
||||||
downloader.currentPlayingIndex, playerPosition
|
downloader.currentPlayingIndex, playerPosition
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user