Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Camera overlay / Custom shutter intermittently works

$
0
0

Hi all,

Building an app with a custom overlay but having issues with taking pictures

Basically it only works sometimes and we can't work out what could be causing it to be so intermittent

We highly suspect its because we switch to the front camera when the camera is opened

iOS7, TiSDK3.2.3, testing on an iPhone 5c

var overlay = Ti.UI.createView({
        top : 0,
        left : 0,
        height : Ti.UI.SIZE,
        width : Ti.UI.SIZE,
    });
 
    var shutterButton = new Image("/media/shutter_pink.png");
 
    var cameraFlip = new Image("/media/camera_flip.png");
    cameraFlip.top = 16, cameraFlip.right = 16;
 
    var galleryButton = new Image("/media/database.png");
    galleryButton.top = 64, galleryButton.right = 16;
 
    shutterButton.addEventListener("touchstart", function() {
        shutterButton.opacity = 0.7;
    });
 
    shutterButton.addEventListener("touchend", function() {
        alert("Why does this sometimes not take the photo?");
        shutterButton.opacity = 1;
        Ti.Media.takePicture();
    });
 
    cameraFlip.addEventListener("touchstart", function() {
        cameraFlip.opacity = 0.7;
    });
 
    cameraFlip.addEventListener("touchend", function() {
        cameraFlip.opacity = 1;
        if (cameraState == 0) {
            Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
            cameraState = 1;
        } else {
            Ti.Media.switchCamera(Ti.Media.CAMERA_REAR);
            cameraState = 0;
        };
    });
 
overlay.add(shutterButton);
    overlay.add(cameraFlip);
    overlay.add(galleryButton);
    Ti.Media.showCamera({
        success : function(e) {
 
            // Manually hide camera interface
            Ti.Media.hideCamera();
            var DLAView = require("/ui/views/DLAView");
            parent.remove(self);
            parent.add(new DLAView(parent, e.media));
        },
        error : function(e) {
            alert("Error: " + JSON.stringify(e));
        },
        cancel : function() {
            alert("Cancel");
        },
        overlay : overlay,
        autoHide : false,
        showControls : false,
    });
 
    Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>