summaryrefslogtreecommitdiffstats
path: root/app/MediaPlayer.qml
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-04-03 16:35:57 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-05-14 18:36:28 -0700
commit21ac475cd8621747169d11c58add5a53a50986a8 (patch)
treeb0f9445895af1955a2afd65331fa750d84ab7911 /app/MediaPlayer.qml
parent4983b81778f718386edd1189a242604f2a78b016 (diff)
libqtappfw: mediaplayer: switch from qml websockets to libqtappfw
Switch agl-service-mediaplayer access from QML websockets to proper libqtappfw middleware. Bug-AGL: SPEC-1375 Change-Id: I406d98701bdc725fe90846d238ec90c9f5aa5b20 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'app/MediaPlayer.qml')
-rw-r--r--app/MediaPlayer.qml85
1 files changed, 71 insertions, 14 deletions
diff --git a/app/MediaPlayer.qml b/app/MediaPlayer.qml
index ebd5324..bab2bd7 100644
--- a/app/MediaPlayer.qml
+++ b/app/MediaPlayer.qml
@@ -24,9 +24,64 @@ import 'api' as API
ApplicationWindow {
id: root
- API.MediaPlayer {
+ Item {
id: player
- url: bindingAddress
+
+ property string title: ""
+ property string album: ""
+ property string artist: ""
+
+ property int duration: 0
+ property int position: 0
+
+ property string cover_art: ""
+ property string status: ""
+
+ function time2str(value) {
+ return Qt.formatTime(new Date(value), 'mm:ss')
+ }
+ }
+
+ Connections {
+ target: mediaplayer
+
+ onPlaylistChanged: {
+ playlist_model.clear();
+
+ for (var i = 0; i < playlist.list.length; i++) {
+ var item = playlist.list[i]
+
+ playlist_model.append({ "index": item.index, "artist": item.artist ? item.artist : '', "title": item.title ? item.title : '' })
+
+ if (item.selected) {
+ playlistview.currentIndex = i
+ }
+ }
+ }
+
+ onMetadataChanged: {
+ player.title = metadata.title
+ player.album = metadata.album
+ player.artist = metadata.artist
+
+ if (metadata.duration) {
+ player.duration = metadata.duration
+ }
+
+ if (metadata.position) {
+ player.position = metadata.position
+ }
+
+ if (metadata.status) {
+ player.status = metadata.status
+ }
+
+ if (metadata.image) {
+ player.cover_art = metadata.image
+ }
+
+ playlistview.currentIndex = metadata.index
+ }
}
API.BluetoothManager {
@@ -45,7 +100,7 @@ ApplicationWindow {
}
ListModel {
- id: playlist
+ id: playlist_model
}
ColumnLayout {
@@ -94,10 +149,10 @@ ApplicationWindow {
ToggleButton {
id: loop
visible: bluetooth.connected == false
- checked: player.loop_state
+ //checked: player.loop_state
offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
- onClicked: { player.loop(checked) }
+ onClicked: { mediaplayer.loop(checked) }
}
}
ColumnLayout {
@@ -144,7 +199,7 @@ ApplicationWindow {
font.pixelSize: 32
text: bluetooth.av_connected ? player.time2str(bluetooth.duration) : player.time2str(player.duration)
}
- onPressedChanged: player.seek(value)
+ onPressedChanged: mediaplayer.seek(value)
}
RowLayout {
Layout.fillHeight: true
@@ -163,7 +218,7 @@ ApplicationWindow {
bluetooth.sendMediaCommand("Previous")
bluetooth.position = 0
} else {
- player.previous()
+ mediaplayer.previous()
}
}
}
@@ -174,16 +229,19 @@ ApplicationWindow {
if (bluetooth.av_connected) {
bluetooth.sendMediaCommand("Play")
} else {
- player.play()
+ mediaplayer.play()
}
}
states: [
State {
- when: player.running === true
+ when: player.status == "playing"
PropertyChanges {
target: play
offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
- onClicked: player.pause()
+ onClicked: {
+ player.status = ""
+ mediaplayer.pause()
+ }
}
},
State {
@@ -204,7 +262,7 @@ ApplicationWindow {
if (bluetooth.av_connected) {
bluetooth.sendMediaCommand("Next")
} else {
- player.next()
+ mediaplayer.next()
}
}
}
@@ -244,7 +302,7 @@ ApplicationWindow {
text: 'PLAYLIST'
opacity: 0.5
}
- model: playlist
+ model: playlist_model
currentIndex: -1
delegate: MouseArea {
@@ -275,8 +333,7 @@ ApplicationWindow {
//}
}
onClicked: {
- player.pick_track(playlistview.model.get(index).index)
- player.play()
+ mediaplayer.picktrack(playlistview.model.get(index).index)
}
}