Fixed VideoPlayerPage.qml failure to set cameraConfig
[harmattan/cameraplus] / qml / PipelineManager.qml
index cd33a48..0ef0a68 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+import QtQuick 2.0
 import QtCamera 1.0
 import CameraPlus 1.0
 
@@ -36,6 +36,7 @@ Item {
     property Camera camera: null
     property Item currentItem
     property bool error: false
+    property int currentPolicyMode: CameraResources.None
 
     onCurrentItemChanged: {
         if (state == "on" || state == "policyLost") {
@@ -59,17 +60,25 @@ Item {
     function startCamera() {
         if (error) {
             return
+        } else if ((currentPolicyMode == currentItem.policyMode) && camera.running) {
+            return
         } else if (!policy.acquire(currentItem.policyMode)) {
             console.log("Failed to acquire policy resources")
             return
+        } else if (currentItem.policyMode == CameraResources.Player) {
+            currentPolicyMode = CameraResources.Player
+            camera.stop(true)
         } else if (!camera.start()) {
             showError(qsTr("Failed to start camera. Please restart the application."))
+        } else {
+            currentPolicyMode = currentItem.policyMode
         }
     }
 
     function stopCamera() {
         if (camera.stop(false)) {
             policy.acquire(CameraResources.None)
+            currentPolicyMode = CameraResources.None
             error = false
         }
     }
@@ -79,6 +88,7 @@ Item {
         // when they become available
         currentItem.policyLost()
         camera.stop(true)
+        currentPolicyMode = CameraResources.None
         error = false
     }