Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23687] Windows: Camera can default to front facing camera on some devices

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-08-03T08:21:04.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.0
ComponentsWindows
Labelsn/a
ReporterGary Mathews
AssigneeGary Mathews
Created2016-07-26T18:14:34.000+0000
Updated2016-10-07T14:45:58.000+0000

Description

On my Lumia 1020, the front facing camera is the default camera. However, I would expect the rear facing camera to be the default. Investigating shows that neither the front or rear cameras of my device have the device->IsDefault flag set to true. In this case, we should determine the correct camera to use and default to that. *Test Case* Setting whichCamera: Titanium.Media.CAMERA_FRONT should show front camera preview.
var win = Ti.UI.createWindow({ backgroundColor: 'green', layout: 'vertical' }),
    openButton = Ti.UI.createButton({ title: 'OPEN CAMERA', backgroundColor: 'blue' }),
    imageView = Ti.UI.createImageView({ width: Ti.UI.FILL, height: '70%' });

var overlay = Ti.UI.createView({
    layout: 'vertical',
    height: '20%', width: Ti.UI.FILL,
    bottom: 0
}),
takeButton = Ti.UI.createButton({ title: 'TAKE A PHOTO', backgroundColor: 'red' }),
hideButton = Ti.UI.createButton({ title: 'HIDE PREVIEW', backgroundColor: 'red' });

takeButton.addEventListener('click', function () {
    Ti.Media.takePicture();
});
hideButton.addEventListener('click', function () {
    Ti.Media.hideCamera();
});
overlay.add(takeButton);
overlay.add(hideButton);

openButton.addEventListener('click', function () {
    Ti.Media.showCamera({
        whichCamera: Titanium.Media.CAMERA_FRONT, // Titanium.Media.CAMERA_REAR
        mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
        overlay: overlay,
        success: function (e) {
            Ti.API.info('showCamera() success');
            imageView.image = e.media;
        },
        error: function (e) {
            alert('showCamera() error: ' + JSON.stringify(e));
        }
    });
});

win.add(openButton);
win.add(imageView);
win.open();

Comments

  1. Gary Mathews 2016-08-02

    master: https://github.com/appcelerator/titanium_mobile_windows/pull/797
  2. Ewan Harris 2016-10-07

    Verified using: OS: Microsoft Windows 10 Pro 10.0.14393 Appc core: 6.0.0-57 Appc NPM: 4.2.8-7 Ti SDK: 6.0.0.v20161006171259 Appc Studio: 4.8.0.201610060953 Camera defaults to rear facing camera Closing ticket

JSON Source