+ Item {
+ id: bluetooth
+ property bool connected: false
+ property string state
+
+ property string artist
+ property string title
+ property int duration: 0
+ property int position: 0
+
+ function disableBluetooth() {
+ bluetooth.artist = ''
+ bluetooth.title = ''
+ bluetooth.duration = 0
+ bluetooth.position = 0
+ bluetooth.connected = false
+ }
+ }
+
+ Connections {
+ target: dbus
+
+ onProcessPlaylistUpdate: {
+ playlist.clear()
+ playlist.addItems(mediaFiles)
+
+ playlistmodel.setSource(playlist)
+ playlistview.visible = bluetooth.connected == false
+ }
+
+ onProcessPlaylistHide: {
+ playlistview.visible = false
+ player.stop()
+ }
+
+ onProcessPlaylistShow: {
+ playlistview.visible = true
+ bluetooth.disableBluetooth()
+ }
+
+ onDisplayBluetoothMetadata: {
+ if (avrcp_artist)
+ bluetooth.artist = avrcp_artist
+ if (avrcp_title)
+ bluetooth.title = avrcp_title
+ bluetooth.duration = avrcp_duration
+ }
+
+ onUpdatePlayerStatus: {
+ bluetooth.connected = true
+ bluetooth.state = status
+ }
+
+ onUpdatePosition: {
+ slider.value = current_position
+ bluetooth.position = current_position
+ }
+ }
+