[Android] Send the favorite status to the remote access
Nicolas Pomepuy
git at videolan.org
Thu Jun 20 12:34:44 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jun 19 15:17:44 2024 +0200| [f1825762e01a625596a074f4c8ce57de06f03814] | committer: Nicolas Pomepuy
Send the favorite status to the remote access
> https://code.videolan.org/videolan/vlc-android/commit/f1825762e01a625596a074f4c8ce57de06f03814
---
.../videolan/vlc/webserver/RemoteAccessRouting.kt | 20 ++++++++++----------
.../org/videolan/vlc/webserver/RemoteAccessServer.kt | 4 ++--
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt
index 51a6bd472e..41aefd7bf0 100644
--- a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt
+++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt
@@ -702,7 +702,7 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) {
val list = ArrayList<RemoteAccessServer.PlayQueueItem>()
RemoteAccessServer.getInstance(appContext).networkSharesLiveData.getList().forEachIndexed { index, mediaLibraryItem ->
list.add(RemoteAccessServer.PlayQueueItem(3000L + index, mediaLibraryItem.title, " ", 0, mediaLibraryItem.artworkMrl
- ?: "", false, "", (mediaLibraryItem as MediaWrapper).uri.toString(), true))
+ ?: "", false, "", (mediaLibraryItem as MediaWrapper).uri.toString(), true, favorite = mediaLibraryItem.isFavorite))
}
val gson = Gson()
call.respondText(gson.toJson(list))
@@ -715,7 +715,7 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) {
val list = ArrayList<RemoteAccessServer.PlayQueueItem>()
stream.forEachIndexed { index, mediaLibraryItem ->
list.add(RemoteAccessServer.PlayQueueItem(3000L + index, mediaLibraryItem.title, " ", 0, mediaLibraryItem.artworkMrl
- ?: "", false, "", (mediaLibraryItem as MediaWrapper).uri.toString(), true))
+ ?: "", false, "", (mediaLibraryItem as MediaWrapper).uri.toString(), true, favorite = mediaLibraryItem.isFavorite))
}
val gson = Gson()
call.respondText(gson.toJson(list))
@@ -1263,7 +1263,7 @@ private suspend fun getProviderContent(context:Context, provider: BrowserProvide
&& mediaLibraryItem is MediaWrapper) mediaLibraryItem.fileName else mediaLibraryItem.title
val isFolder = if (mediaLibraryItem is MediaWrapper) mediaLibraryItem.type == MediaWrapper.TYPE_DIR else true
list.add(RemoteAccessServer.PlayQueueItem(idPrefix + index, title, description, 0, mediaLibraryItem.artworkMrl
- ?: "", false, "", path, isFolder))
+ ?: "", false, "", path, isFolder, favorite = mediaLibraryItem.isFavorite))
}
return list
}
@@ -1272,23 +1272,23 @@ private suspend fun getProviderContent(context:Context, provider: BrowserProvide
fun Album.toPlayQueueItem() = RemoteAccessServer.PlayQueueItem(id, title, albumArtist
?: "", duration, artworkMrl
- ?: "", false, "")
+ ?: "", false, "", favorite = isFavorite)
fun Artist.toPlayQueueItem(appContext: Context) = RemoteAccessServer.PlayQueueItem(id, title, appContext.resources.getQuantityString(R.plurals.albums_quantity, albumsCount, albumsCount), 0, artworkMrl
- ?: "", false, "")
+ ?: "", false, "", favorite = isFavorite)
fun Genre.toPlayQueueItem(appContext: Context) = RemoteAccessServer.PlayQueueItem(id, title, appContext.resources.getQuantityString(R.plurals.track_quantity, tracksCount, tracksCount), 0, artworkMrl
- ?: "", false, "")
+ ?: "", false, "", favorite = isFavorite)
fun Playlist.toPlayQueueItem(appContext: Context) = RemoteAccessServer.PlayQueueItem(id, title, appContext.resources.getQuantityString(R.plurals.track_quantity, tracksCount, tracksCount), 0, artworkMrl
- ?: "", false, "")
+ ?: "", false, "", favorite = isFavorite)
fun MediaWrapper.toPlayQueueItem(defaultArtist: String = "") = RemoteAccessServer.PlayQueueItem(id, title, artist?.ifEmpty { defaultArtist } ?: defaultArtist, length, artworkMrl
- ?: "", false, generateResolutionClass(width, height) ?: "", progress = time, played = seen > 0)
+ ?: "", false, generateResolutionClass(width, height) ?: "", progress = time, played = seen > 0, favorite = isFavorite)
fun Folder.toPlayQueueItem(context: Context) = RemoteAccessServer.PlayQueueItem(id, title, context.resources.getQuantityString(org.videolan.vlc.R.plurals.videos_quantity, mediaCount(Folder.TYPE_FOLDER_VIDEO), mediaCount(Folder.TYPE_FOLDER_VIDEO))
?: "", 0, artworkMrl
- ?: "", false,"", videoType = "video-folder")
+ ?: "", false, "", videoType = "video-folder", favorite = isFavorite)
fun VideoGroup.toPlayQueueItem(context: Context) = RemoteAccessServer.PlayQueueItem(id, title, if (this.mediaCount() > 1) context.resources.getQuantityString(org.videolan.vlc.R.plurals.videos_quantity, this.mediaCount(), this.mediaCount()) else "length", 0, artworkMrl
- ?: "", false,"", videoType = "video-group", played = presentSeen == presentCount && presentCount != 0)
\ No newline at end of file
+ ?: "", false, "", played = presentSeen == presentCount && presentCount != 0, videoType = "video-group", favorite = isFavorite)
\ No newline at end of file
diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt
index 0c7e76308f..7c93923e1d 100644
--- a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt
+++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt
@@ -607,7 +607,7 @@ class RemoteAccessServer(private val context: Context) : PlaybackService.Callbac
service.playlistManager.getMediaList().forEachIndexed { index, mediaWrapper ->
list.add(PlayQueueItem(mediaWrapper.id, mediaWrapper.title, mediaWrapper.artist
?: "", mediaWrapper.length, mediaWrapper.artworkMrl
- ?: "", service.playlistManager.currentIndex == index))
+ ?: "", service.playlistManager.currentIndex == index, favorite = mediaWrapper.isFavorite))
}
val gson = Gson()
return gson.toJson(PlayQueue(list))
@@ -747,7 +747,7 @@ class RemoteAccessServer(private val context: Context) : PlaybackService.Callbac
data class WSBookmark(val title: String, val time: Long)
data class PlayQueue(val medias: List<PlayQueueItem>) : WSMessage("play-queue")
- data class PlayQueueItem(val id: Long, val title: String, val artist: String, val length: Long, val artworkURL: String, val playing: Boolean, val resolution: String = "", val path: String = "", val isFolder: Boolean = false, val progress: Long = 0L, val played: Boolean = false, val fileType: String = "", val videoType:String? = null)
+ data class PlayQueueItem(val id: Long, val title: String, val artist: String, val length: Long, val artworkURL: String, val playing: Boolean, val resolution: String = "", val path: String = "", val isFolder: Boolean = false, val progress: Long = 0L, val played: Boolean = false, val fileType: String = "", val videoType: String? = null, val favorite: Boolean = false)
data class WebSocketAuthorization(val status:String, val initialMessage:String) : WSMessage("auth")
data class Volume(val volume: Int) : WSMessage("volume")
data class PlayerStatus(val playing: Boolean) : WSMessage("player-status")
More information about the Android
mailing list