[TIMOB-23687] Windows: Camera can default to front facing camera on some devices
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-08-03T08:21:04.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 6.0.0 |
| Components | Windows |
| Labels | n/a |
| Reporter | Gary Mathews |
| Assignee | Gary Mathews |
| Created | 2016-07-26T18:14:34.000+0000 |
| Updated | 2016-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();
master: https://github.com/appcelerator/titanium_mobile_windows/pull/797
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