Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1232] camera with flash on freezes

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2011-04-15T02:47:16.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.4.0
ComponentsiOS
Labelsios, iphone
ReporterNolan Wright
AssigneeJeff Haynie
Created2011-04-15T02:47:16.000+0000
Updated2017-03-02T19:23:10.000+0000

Description

see attached example. toggle flash to on, take picture and app freezes


// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('FFF');

// create tab group
var tabGroup = Titanium.UI.createTabGroup();

//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Camera Flash Test',
    backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Camera',
    window:win1
});

function isiOS4Plus()
{
    // add iphone specific tests
    if (Titanium.Platform.name == 'iPhone OS')
    {
        var version = Titanium.Platform.version.split(".");
        var major = parseInt(version[0], 10);

        // can only test this support on a 3.2+ device
        if (major >= 4)
        {
            return true;
        }
    }
    return false;
}

var cameraButton = Ti.UI.createButton({
    title:'Camera Test',
    height:40,
    width: 280,
    left:20,
    top:300
});
cameraButton.addEventListener('click', function () {

    if (isiOS4Plus())
    {
        Ti.Media.cameraFlashMode = Ti.Media.CAMERA_FLASH_OFF;
    }
    
    var overlayView = Ti.UI.createView({
        height:480,
        width:320,
        backgroundColor:'transparent'
    });

    var cameraFlash = Titanium.UI.createButton({
        title:'Flash: Off',
        height:30,
        width:100,
        left:20,
        top:20,
        borderRadius:8
    });
    cameraFlash.addEventListener('click', function() {

        if (!isiOS4Plus())
        {
            return;
        }
        
        if (Ti.Media.cameraFlashMode == Ti.Media.CAMERA_FLASH_ON)
        {
            cameraFlash.title = "Flash: Off";
            Ti.Media.cameraFlashMode = Ti.Media.CAMERA_FLASH_OFF;
        }
        else
        {
            cameraFlash.title = "Flash: On";
            Ti.Media.cameraFlashMode = Ti.Media.CAMERA_FLASH_ON;
        }
    });
        
    var button1 = Titanium.UI.createButton({
        title:'Shoot',
        height:40,
        width:100,
        left:110,
        top:5
    });
    button1.addEventListener('click', function() {
        Ti.Media.takePicture();
    });

    var button2 = Titanium.UI.createButton({
        title:'Done',
        height:40,
        width:100,
        left:5,
        top:5
    });
    button2.addEventListener('click', function() {
        Ti.Media.hideCamera();
    });
    
    var background = Ti.UI.createView({
        height:50,
        width:320,
        backgroundColor:'black',
        bottom:0
    });  

    background.add(button1);
    background.add(button2);

    overlayView.add(background);
    overlayView.add(cameraFlash);

    Titanium.Media.showCamera({
        
        success:function(event)
        {        
        },
        
        cancel:function()
        {
        },
        error:function(error)
        {
        },
        showControls:false,
        allowImageEditing:false,
        autohide:false,
        mediaTypes:Ti.Media.MEDIA_TYPE_PHOTO,
        overlay:overlayView,
        saveToPhotoGallery:true
    });
});


win1.add(cameraButton);

tabGroup.addTab(tab1);  

// open tab group
tabGroup.open();

Comments

  1. Jeff Haynie 2011-04-15

    this is an invalid test. see KS camera_overlay.js or camera_overlay_webview.js for examples

    since you are calling takePicture, you'll have to either (a) set autohide:true or (b) call Ti.Media.hideCamera().

    when you don't have the flash on, the interface won't show the camera flash indicator (the swirley looking image) - however, when you have a flash, it will. To cause the interface to close, you'll have to call hideCamera.

    I've verified this with a standalone XCode project outside of Titanium.

    I'm not sure if this is a bug or not in 4.0. It seems like the only way to do continuous pictures is to ensure that the flash is off so it doesn't show the flash view.

  2. Lee Morris 2017-03-02

    Closed as invalid.

JSON Source