[Android] Better file icons for remote access

Nicolas Pomepuy git at videolan.org
Wed Feb 7 06:50:56 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jan 15 14:46:22 2024 +0100| [7430841aa5f2bf89d07f8495760b684253d0d6a2] | committer: Nicolas Pomepuy

Better file icons for remote access

> https://code.videolan.org/videolan/vlc-android/commit/7430841aa5f2bf89d07f8495760b684253d0d6a2
---

 .../java/org/videolan/vlc/webserver/RemoteAccessRouting.kt   | 12 +++++++++++-
 .../java/org/videolan/vlc/webserver/RemoteAccessServer.kt    |  2 +-
 .../network-sharing-server/src/components/MediaListItem.vue  |  3 ++-
 3 files changed, 14 insertions(+), 3 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 3319616ec1..bdb2d81b6e 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
@@ -884,13 +884,23 @@ private suspend fun getProviderContent(context:Context, provider: BrowserProvide
                 && (provider.url == null || Uri.parse(provider.url).scheme.isSchemeFile())
                 && mediaLibraryItem is MediaWrapper) mediaLibraryItem.fileName else mediaLibraryItem.title
         val isFolder = if (mediaLibraryItem is MediaWrapper) mediaLibraryItem.type == MediaWrapper.TYPE_DIR else true
+        var type = "folder"
+        if (!isFolder) {
+            type = when ((mediaLibraryItem as MediaWrapper).type) {
+                MediaWrapper.TYPE_AUDIO -> "audio"
+                MediaWrapper.TYPE_VIDEO -> "video"
+                MediaWrapper.TYPE_SUBTITLE -> "subtitle"
+                else -> "file"
+            }
+        }
         list.add(RemoteAccessServer.PlayQueueItem(idPrefix + index, title, description, 0, mediaLibraryItem.artworkMrl
-                ?: "", false, "", path, isFolder))
+                ?: "", false, "", path, isFolder, fileType = type))
     }
     return list
 }
 
 
+
 fun Album.toPlayQueueItem() = RemoteAccessServer.PlayQueueItem(id, title, albumArtist
         ?: "", duration, artworkMrl
         ?: "", false, "")
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 753400de55..429206f547 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
@@ -738,7 +738,7 @@ class RemoteAccessServer(private val context: Context) : PlaybackService.Callbac
             ?: false) : WSMessage("now-playing")
 
     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)
+    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 = "")
     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")
diff --git a/buildsystem/network-sharing-server/src/components/MediaListItem.vue b/buildsystem/network-sharing-server/src/components/MediaListItem.vue
index 0c1db7bb31..848fdde1da 100644
--- a/buildsystem/network-sharing-server/src/components/MediaListItem.vue
+++ b/buildsystem/network-sharing-server/src/components/MediaListItem.vue
@@ -1,7 +1,8 @@
 <template>
     <div class="d-flex clickable media-img-list-tr">
         <div v-on:click="manageClick" class="ratio media-img-container" v-bind:class="(mainImgClasses())">
-            <img v-lazy="$getImageUrl(media, this.mediaType)" class="media-img-list">
+            <img v-if="this.mediaType == 'file'" v-lazy="$getImageUrl(media, media.fileType)" class="media-img-list">
+            <img v-else v-lazy="$getImageUrl(media, this.mediaType)" class="media-img-list">
             <div class="media-overlay" v-show="!isBrowse()">
                 <img class="overlay-play" :src="(`./icons/play_circle_white.svg`)" width="24" />
             </div>



More information about the Android mailing list