From 8fd69e6ed95dce58bb5f40e3b9548380cfb555dd Mon Sep 17 00:00:00 2001 From: lalilu <1248393538@qq.com> Date: Fri, 13 Dec 2024 09:37:27 +0800 Subject: [PATCH] =?UTF-8?q?[refactor]=E4=BF=AE=E6=AD=A3MService=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lplayer/src/main/java/com/lalilu/lplayer/MPlayer.kt | 12 ++---------- .../main/java/com/lalilu/lplayer/service/MService.kt | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lplayer/src/main/java/com/lalilu/lplayer/MPlayer.kt b/lplayer/src/main/java/com/lalilu/lplayer/MPlayer.kt index ef182606..9f9a0546 100644 --- a/lplayer/src/main/java/com/lalilu/lplayer/MPlayer.kt +++ b/lplayer/src/main/java/com/lalilu/lplayer/MPlayer.kt @@ -187,14 +187,6 @@ object MPlayer : CoroutineScope { updateItems(timeline) } - override fun onRepeatModeChanged(repeatMode: Int) { - super.onRepeatModeChanged(repeatMode) - } - - override fun onShuffleModeEnabledChanged(shuffleModeEnabled: Boolean) { - super.onShuffleModeEnabledChanged(shuffleModeEnabled) - } - fun updateItems( timeline: Timeline = browser.currentTimeline, currentIndex: Int = browser.currentMediaItemIndex @@ -208,12 +200,12 @@ object MPlayer : CoroutineScope { } } -fun Timeline.toMediaItems(): List { +private fun Timeline.toMediaItems(): List { return (0 until this.windowCount) .mapNotNull { this.getWindow(it, Timeline.Window()).mediaItem } } -fun Timeline.indexOf(mediaId: String): Int { +private fun Timeline.indexOf(mediaId: String): Int { return (0 until this.windowCount).firstOrNull { this.getWindow(it, Timeline.Window()) .mediaItem.mediaId == mediaId diff --git a/lplayer/src/main/java/com/lalilu/lplayer/service/MService.kt b/lplayer/src/main/java/com/lalilu/lplayer/service/MService.kt index 9a30a564..60afaacc 100644 --- a/lplayer/src/main/java/com/lalilu/lplayer/service/MService.kt +++ b/lplayer/src/main/java/com/lalilu/lplayer/service/MService.kt @@ -116,7 +116,7 @@ private class MServiceCallback(private val player: Player) : MediaLibrarySession controller: MediaSession.ControllerInfo ): MediaSession.ConnectionResult { val sessionCommands = MediaSession.ConnectionResult - .DEFAULT_SESSION_COMMANDS.buildUpon() + .DEFAULT_SESSION_AND_LIBRARY_COMMANDS.buildUpon() .registerCustomCommands() .build()