[TIMOB-23686] Windows: Implement CameraOptionsType.whichCamera
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-08-03T08:22:58.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:09:35.000+0000 |
Updated | 2016-08-29T13:13:45.000+0000 |
Description
Currently, it is not possible to specify which camera (front or rear) to use.
Use
DeviceInformation::FindAllAsync(DeviceClass::VideoCapture)
to find the Id
of the specified camera and set the VideoDeviceId
of MediaCaptureInitializationSettings
*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: Windows 10 Pro Appc core: 6.0.0-31 Appc NPM: 4.2.8-5 Ti SDK: 6.0.0.v20160829005859 Lumia 520 8.1 Lumia 930 10.0 Using the example code above the camera preview can be set to either the front or back, setting an invalid option or no option will set it to the default for the device Closing ticket