From 4eee2655560fbb2f7724095bb7fa488f3f39ba55 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 30 Mar 2017 15:05:03 -0700 Subject: dbus: add signal support for removable media Detect media insertation and removal from lightmediascanner and update the playlist accordingly. This makes some assumptions that only one media device will available at a time. Bug-AGL: SPEC-484 Change-Id: I8300abce3ac09c9cd0327c9d90892e3c5171d8d2 Signed-off-by: Matt Ranostay --- app/MediaPlayer.qml | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'app/MediaPlayer.qml') diff --git a/app/MediaPlayer.qml b/app/MediaPlayer.qml index 37c2ab1..dae74a0 100644 --- a/app/MediaPlayer.qml +++ b/app/MediaPlayer.qml @@ -24,6 +24,32 @@ import MediaPlayer 1.0 ApplicationWindow { id: root + function clearMetadata() { + title.text = '' + artist.text = '' + duration.text = player.time2str(0) + albumart.visible = false + } + + Connections { + target: dbus + onProcessPlaylistUpdate: { + playlist.clear() + playlist.addItems(mediaFiles) + + playlistmodel.setSource(playlist) + playlistview.visible = true + albumart.visible = true + } + + onProcessPlaylistHide: { + player.stop() + playlistview.visible = false + clearMetadata() + } + + } + MediaPlayer { id: player audioRole: MediaPlayer.MusicRole @@ -53,6 +79,7 @@ ApplicationWindow { Layout.preferredHeight: 1080 clip: true Image { + id: albumart anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom @@ -178,17 +205,22 @@ ApplicationWindow { Layout.fillWidth: true Layout.fillHeight: true Layout.preferredHeight: 407 + + PlaylistWithMetadata { + id: playlistmodel + source: playlist + } + ListView { anchors.fill: parent + id: playlistview clip: true header: Label { x: 50 text: 'PLAYLIST' opacity: 0.5 } - model: PlaylistWithMetadata { - source: playlist - } + model: playlistmodel currentIndex: playlist.currentIndex delegate: MouseArea { -- cgit 1.2.3-korg