Remote access: generate browser items using the ml MediaWrapper if possible

This commit is contained in:
Nicolas Pomepuy
2025-08-20 14:51:45 +02:00
parent 09b84b8bc3
commit d89e83b690
2 changed files with 14 additions and 4 deletions

View File

@@ -944,8 +944,18 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) {
else -> "file"
}
}
RemoteAccessServer.PlayQueueItem(1000L + index, title, it.description ?: "", 0, it.artworkMrl
?: "", false, "", filePath, isFolder, fileType = fileType)
val id = if (it is MediaWrapper && it.id > 0) it.id else 1000L + index
val played = if (it is MediaWrapper) it.seen > 0 else false
if (it is MediaWrapper && it.id > 0) {
it.toPlayQueueItem().apply {
this.fileType = fileType
this.artist = it.description
}
} else
RemoteAccessServer.PlayQueueItem(
id, title, it.description ?: "", 0, it.artworkMrl
?: "", false, "", filePath, isFolder, fileType = fileType, played = played)
}
//segments
@@ -1616,7 +1626,7 @@ fun Playlist.toPlayQueueItem(appContext: Context) = RemoteAccessServer.PlayQueue
?: "", false, "", favorite = isFavorite)
fun MediaWrapper.toPlayQueueItem(defaultArtist: String = "") = RemoteAccessServer.PlayQueueItem(id, title, artistName?.ifEmpty { defaultArtist } ?: defaultArtist, length, artworkMrl
?: "", false, generateResolutionClass(width, height) ?: "", progress = time, played = seen > 0, favorite = isFavorite)
?: "", false, generateResolutionClass(width, height) ?: "", progress = time, played = seen > 0, favorite = isFavorite, path = uri.toString())
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

View File

@@ -1000,7 +1000,7 @@ class RemoteAccessServer(private val context: Context) : PlaybackService.Callbac
data class WSChapter(val title: String, val time: Long)
data class PlayQueue(val medias: List<PlayQueueItem>) : WSMessage(WSMessageType.PLAY_QUEUE)
data class PlayQueueItem(val id: Long, val title: String, val artist: String, val duration: 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, var fileType: String = "", val favorite: Boolean = false)
data class PlayQueueItem(val id: Long, val title: String, var artist: String, val duration: 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, var fileType: String = "", val favorite: Boolean = false)
data class WebSocketAuthorization(val status:String, val initialMessage:String) : WSMessage(WSMessageType.AUTH)
data class Volume(val volume: Int) : WSMessage(WSMessageType.VOLUME)
data class PlayerStatus(val playing: Boolean) : WSMessage(WSMessageType.PLAYER_STATUS)