Added the ability to control playback volume from post capture
[harmattan/cameraplus] / qml / VideoPlayerPage.qml
index 535510e..8d78df3 100644 (file)
@@ -55,15 +55,52 @@ Item {
         onTriggered: toolBar.show = false
     }
 
+    DeviceKeys {
+        id: zoomKeys
+        active: Qt.application.active && pipelineManager.scaleAcquired
+        repeat: true
+
+        onVolumeUpPressed: {
+            timer.restart()
+            video.volume = Math.min(video.volume + 2, 100)
+        }
+
+        onVolumeDownPressed: {
+            timer.restart()
+            video.volume = Math.max(video.volume - 2, 0)
+        }
+    }
+
     VideoPlayer {
+        Rectangle {
+            id: volumeControl
+            anchors.top: parent.top
+            anchors.left: parent.left
+            width: (parent.width * video.volume) / 100
+            color: "blue"
+            border.color: "black"
+            height: 25
+            opacity: timer.running ? 1.0 : 0.0
+
+            Behavior on opacity {
+                NumberAnimation { duration: 250 }
+            }
+
+            Timer {
+                id: timer
+                interval: 500
+                repeat: false
+            }
+        }
+
         id: video
         anchors.fill: parent
-        cameraConfig: cam.cameraConfig
+        cameraConfig: camera.cameraConfig
 
         onError: showError(qsTr("Error playing video. Please try again or restart the application"))
 
         function toggle() {
-            if (!video.paused) {
+            if (state != VideoPlayer.StatePaused) {
                 video.pause()
             } else {
                 page.play()
@@ -94,20 +131,22 @@ Item {
         hideBack: true
         expanded: true
         anchors.bottom: parent.bottom
-        anchors.bottomMargin: show ? 20 : -1 * (height + 20)
+        anchors.bottomMargin: 20
         anchors.left: parent.left
         anchors.leftMargin: 20
-        opacity: 0.5
+        opacity: show ? 0.8 : 0.0
+        visible: opacity > 0
 
-        Behavior on anchors.bottomMargin {
+        Behavior on opacity {
             PropertyAnimation { duration: 200; }
         }
 
-        items: [
+        tools: CameraToolBarTools {
             CameraToolIcon {
-                iconId: "icon-m-toolbar-mediacontrol-stop-white"
+                iconSource: cameraTheme.videoStopIconId
                 onClicked: video.stop()
-            },
+            }
+
             CameraSlider {
                 id: slider
                 height: toolBar.height
@@ -128,16 +167,16 @@ Item {
 
                     hideTimer.restart()
                 }
-            },
+            }
+
             CameraToolIcon {
                 id: control
-                iconId: !video.paused ? "icon-m-toolbar-mediacontrol-pause-white"
-                    : "icon-m-toolbar-mediacontrol-play-white"
+                iconSource: video.state != VideoPlayer.StatePaused ? cameraTheme.videoPauseIconId : cameraTheme.videoPlayIconId
                 onClicked: {
                     video.toggle()
                     hideTimer.restart()
                 }
             }
-        ]
+        }
     }
 }