cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rakat...@apache.org
Subject cordova-plugin-camera git commit: CB-10414: Adding focus handler to resume video when user comes back on leaving the app while preview was running
Date Thu, 03 Mar 2016 18:12:48 GMT
Repository: cordova-plugin-camera
Updated Branches:
  refs/heads/master 56b946931 -> 9c906b2ab


CB-10414: Adding focus handler to resume video when user comes back on leaving the app while
preview was running


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/9c906b2a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/9c906b2a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/9c906b2a

Branch: refs/heads/master
Commit: 9c906b2ab7e7bee031abd85be13910a2a67754ca
Parents: 56b9469
Author: Raghav Katyal <rakatyal@microsoft.com>
Authored: Wed Mar 2 14:15:01 2016 -0800
Committer: Raghav Katyal <rakatyal@microsoft.com>
Committed: Wed Mar 2 14:15:01 2016 -0800

----------------------------------------------------------------------
 src/windows/CameraProxy.js | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/9c906b2a/src/windows/CameraProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/CameraProxy.js b/src/windows/CameraProxy.js
index 0eb7d3d..e0be5b8 100644
--- a/src/windows/CameraProxy.js
+++ b/src/windows/CameraProxy.js
@@ -351,12 +351,22 @@ function takePictureFromCameraWP(successCallback, errorCallback, args)
{
         captureSettings.streamingCaptureMode = CaptureNS.StreamingCaptureMode.video;
     }
 
+    function continueVideoOnFocus() {
+        // if preview is defined it would be stuck, play it
+        if (capturePreview) {
+            capturePreview.play();
+        }
+    }
+
     function startCameraPreview() {
         // Search for available camera devices
         // This is necessary to detect which camera (front or back) we should use
         var DeviceEnum = Windows.Devices.Enumeration;
         var expectedPanel = cameraDirection === 1 ? DeviceEnum.Panel.front : DeviceEnum.Panel.back;
 
+        // Add focus event handler to capture the event when user suspends the app and comes
back while the preview is on
+        window.addEventListener("focus", continueVideoOnFocus);
+
         DeviceEnum.DeviceInformation.findAllAsync(DeviceEnum.DeviceClass.videoCapture).then(function
(devices) {
             if (devices.length <= 0) {
                 destroyCameraPreview();
@@ -459,6 +469,9 @@ function takePictureFromCameraWP(successCallback, errorCallback, args)
{
         cameraCaptureButton.removeEventListener('click', onCameraCaptureButtonClick);
         cameraCancelButton.removeEventListener('click', onCameraCancelButtonClick);
 
+        // Remove the focus event handler
+        window.removeEventListener("focus", continueVideoOnFocus);
+
         // Remove elements
         [capturePreview, cameraCaptureButton, cameraCancelButton].forEach(function (elem)
{
             if (elem /* && elem in document.body.childNodes */) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message