diff --git a/Samples/CameraView/Assets/camera_front.png b/Samples/CameraView/Assets/camera_front.png new file mode 100644 index 0000000..3eb24d1 Binary files /dev/null and b/Samples/CameraView/Assets/camera_front.png differ diff --git a/Samples/CameraView/Assets/camera_rear.png b/Samples/CameraView/Assets/camera_rear.png new file mode 100644 index 0000000..8392b2a Binary files /dev/null and b/Samples/CameraView/Assets/camera_rear.png differ diff --git a/Samples/CameraView/Assets/cancel.png b/Samples/CameraView/Assets/cancel.png new file mode 100644 index 0000000..12b0e55 Binary files /dev/null and b/Samples/CameraView/Assets/cancel.png differ diff --git a/Samples/CameraView/Assets/check_circle.png b/Samples/CameraView/Assets/check_circle.png new file mode 100644 index 0000000..542a64b Binary files /dev/null and b/Samples/CameraView/Assets/check_circle.png differ diff --git a/Samples/CameraView/Assets/flash_off.png b/Samples/CameraView/Assets/flash_off.png new file mode 100644 index 0000000..3cf30f3 Binary files /dev/null and b/Samples/CameraView/Assets/flash_off.png differ diff --git a/Samples/CameraView/Assets/flash_on.png b/Samples/CameraView/Assets/flash_on.png new file mode 100644 index 0000000..4e116af Binary files /dev/null and b/Samples/CameraView/Assets/flash_on.png differ diff --git a/Samples/CameraView/Assets/photo_camera.png b/Samples/CameraView/Assets/photo_camera.png new file mode 100644 index 0000000..c8e69dc Binary files /dev/null and b/Samples/CameraView/Assets/photo_camera.png differ diff --git a/Samples/CameraView/Assets/videocam.png b/Samples/CameraView/Assets/videocam.png new file mode 100644 index 0000000..44c28e2 Binary files /dev/null and b/Samples/CameraView/Assets/videocam.png differ diff --git a/Samples/CameraView/CameraView.unoproj b/Samples/CameraView/CameraView.unoproj new file mode 100644 index 0000000..5b6edbb --- /dev/null +++ b/Samples/CameraView/CameraView.unoproj @@ -0,0 +1,13 @@ +{ + "RootNamespace": "", + "Packages": [ + "Fuse", + "FuseJS", + "Fuse.Controls.CameraView", + "Fuse.ImageTools", + "Fuse.CameraRoll" + ], + "Includes": [ + "*" + ] +} \ No newline at end of file diff --git a/Samples/CameraView/MainView.js b/Samples/CameraView/MainView.js new file mode 100644 index 0000000..30e3fc5 --- /dev/null +++ b/Samples/CameraView/MainView.js @@ -0,0 +1,103 @@ +var Observable = require("FuseJS/Observable"); +var ImageTools = require("FuseJS/ImageTools"); +var VideoTools = require("FuseJS/VideoTools"); +var CameraRoll = require("FuseJS/CameraRoll"); + +var image = Observable(""); +var flashIsOn = Observable(false); +var currentMedia = Observable("Photo"); + +var imageObject = {}; + +function capture() { + if (currentMedia.value == "Video") { + if (cameraPanel.IsCurrentlyRecording.value == "Recording") { + stopVideoCapture(); + } else { + startVideoCapture(); + } + } else { + takePicture(); + } +} + +function takePicture() { + cameraPanel.takePicture({callback: function(err, img) { + if (img !== null) { + imageObject = img; + image.value = img.path; + } + }}); +} + +function startVideoCapture() { + cameraPanel.startVideo(); +} + +function stopVideoCapture() { + cameraPanel.endVideo(function(err, path) { + if (err) { + return; + } + VideoTools.copyVideoToCameraRoll(path); + }); +} + +function discardPicture() { + image.value = ""; + flashIsOn.value = false; +} + +function savePicture() { + CameraRoll.publishImage(imageObject); + discardPicture(); +} + +function swapCamera() { + cameraPanel.swapCamera(); +} + +function toggleFlash() { + flashIsOn.value = ! flashIsOn.value; + if (flashIsOn.value) { + cameraPanel.enableFlash(); + } else { + cameraPanel.disableFlash(); + } +} + +function toggleMediaPhoto() { + currentMedia.value = "Photo"; +} + +function toggleMediaVideo() { + currentMedia.value = "Video"; +} + +module.exports = { + image: image, + + capture: capture, + discardPicture: discardPicture, + savePicture: savePicture, + + swapCamera: swapCamera, + cameraDirection: cameraPanel.CurrentCameraDirection.map(function(x) { + return x.substr(0,1); + }), + + toggleFlash: toggleFlash, + flashIsOn: flashIsOn, + + currentMedia: currentMedia, + toggleMediaPhoto: toggleMediaPhoto, + toggleMediaVideo: toggleMediaVideo, + + videoIsRecording: cameraPanel.IsCurrentlyRecording.map(function(x) { + if (x == "Recording") { + return true; + } else { + return false; + } + }) +}; diff --git a/Samples/CameraView/MainView.ux b/Samples/CameraView/MainView.ux new file mode 100644 index 0000000..65bf67e --- /dev/null +++ b/Samples/CameraView/MainView.ux @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/CameraView/README.md b/Samples/CameraView/README.md new file mode 100644 index 0000000..454f460 --- /dev/null +++ b/Samples/CameraView/README.md @@ -0,0 +1 @@ +# Using the CameraView premium library diff --git a/Samples/CameraView/description.yaml b/Samples/CameraView/description.yaml new file mode 100644 index 0000000..45123b9 --- /dev/null +++ b/Samples/CameraView/description.yaml @@ -0,0 +1,2 @@ +name: Using the CameraView premium library +desc: This sample shows how to use the CameraView premium library to build a fully functional camera app.