Add gitreview file for flounder branch
[apps/mediaplayer.git] / app / MediaPlayer.qml
index a0a1455..983087c 100644 (file)
@@ -22,6 +22,9 @@ import AGL.Demo.Controls 1.0
 ApplicationWindow {
     id: root
 
+    width: container.width * container.scale
+    height: container.height * container.scale
+
     Item {
         id: player
 
@@ -33,7 +36,7 @@ ApplicationWindow {
         property int position: 0
 
         property string cover_art: ""
-        property string status: ""
+        property string status: "stopped"
 
         function time2str(value) {
             return Qt.formatTime(new Date(value), 'mm:ss')
@@ -104,8 +107,10 @@ ApplicationWindow {
             if (data.Connected == "False")
                 return
 
-            if (!bluetooth.av_connected && data.AVPConnected == "True")
+            if (!bluetooth.av_connected && data.AVPConnected == "True") {
                 mediaplayer.pause()
+                player.status = "stopped"
+            }
 
             bluetooth.connected = data.Connected == "True"
             bluetooth.av_connected = data.AVPConnected == "True"
@@ -131,20 +136,6 @@ ApplicationWindow {
     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
@@ -180,9 +171,12 @@ ApplicationWindow {
         }
     }
 
-    ListModel {
-        id: playlist_model
-    }
+    Item {
+        id: container
+        anchors.centerIn: parent
+        width: 1080
+        height: 1487
+        scale: screenInfo.scale_factor()
 
     ColumnLayout {
         anchors.fill: parent
@@ -305,22 +299,14 @@ ApplicationWindow {
                         }
                         ImageButton {
                             id: play
-                            offImage: './images/AGL_MediaPlayer_Player_Play.svg'
-                            onClicked: {
-                                if (bluetooth.av_connected) {
-                                    bluetooth.set_avrcp_controls("Play")
-                                } else {
-                                    mediaplayer.play()
-                                }
-                            }
                             states: [
                                 State {
-                                    when: player.status == "playing"
+                                    when: !bluetooth.av_connected && player.status == "playing"
                                     PropertyChanges {
                                         target: play
                                         offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
                                         onClicked: {
-                                            player.status = ""
+                                            player.status = "stopped"
                                             mediaplayer.pause()
                                         }
                                     }
@@ -332,8 +318,23 @@ ApplicationWindow {
                                         offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
                                         onClicked: bluetooth.set_avrcp_controls("Pause")
                                     }
+                                },
+                                State {
+                                    when: !bluetooth.av_connected && player.status != "playing"
+                                    PropertyChanges {
+                                        target: play
+                                        offImage: './images/AGL_MediaPlayer_Player_Play.svg'
+                                        onClicked: mediaplayer.play()
+                                    }
+                                },
+                                State {
+                                    when: bluetooth.av_connected && bluetooth.state != "playing"
+                                    PropertyChanges {
+                                        target: play
+                                        offImage: './images/AGL_MediaPlayer_Player_Play.svg'
+                                        onClicked: bluetooth.set_avrcp_controls("Play")
+                                    }
                                 }
-
                             ]
                         }
                         ImageButton {
@@ -383,7 +384,7 @@ ApplicationWindow {
                     text: 'PLAYLIST'
                     opacity: 0.5
                 }
-                model: playlist_model
+                model: MediaplayerModel
                 currentIndex: -1
 
                 delegate: MouseArea {
@@ -414,7 +415,7 @@ ApplicationWindow {
                         //}
                     }
                     onClicked: {
-                        mediaplayer.picktrack(playlistview.model.get(index).index)
+                        mediaplayer.picktrack(playlistview.model[index].index)
                     }
                 }
 
@@ -426,3 +427,4 @@ ApplicationWindow {
         }
     }
 }
+}