Add VIS vehicle signal support
[apps/mediaplayer.git] / app / MediaPlayer.qml
index 74fcf2e..95bc22b 100644 (file)
@@ -46,6 +46,13 @@ ApplicationWindow {
         }
     }
 
+    Component.onCompleted : {
+        // Let the mediaplayer backend know we're ready for metadata events
+        mediaplayer.start()
+
+        VehicleSignals.connect()
+    }
+
     Connections {
         target: mediaplayer
 
@@ -81,6 +88,33 @@ ApplicationWindow {
         }
     }
 
+    Connections {
+        target: VehicleSignals
+
+        onConnected: {
+           VehicleSignals.authorize()
+        }
+
+        onAuthorized: {
+           VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.Media.Action")
+       }
+
+        onSignalNotification: {
+            if (path === "Vehicle.Cabin.Infotainment.Media.Action") {
+                if (value == "SkipForward") {
+                    mediaplayer.next()
+                } else if (value == "SkipBackward") {
+                    mediaplayer.previous()
+                } else if (value == "NextSource") {
+                    if (player.av_connected)
+                        mediaplayer.connect()
+                    else
+                        mediaplayer.disconnect()
+                }
+            }
+        }
+    }
+
     Timer {
         id: timer
         interval: 250
@@ -258,7 +292,7 @@ ApplicationWindow {
         Item {
             Layout.fillWidth: true
             Layout.fillHeight: true
-            Layout.preferredHeight: container.height / 2
+            Layout.preferredHeight: 407
 
             ListView {
                 anchors.fill: parent