Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15844] Android: Media: Unable to switch to front camera

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2013-12-03T17:31:57.000+0000
Affected Version/sRelease 3.2.0
Fix Version/sn/a
ComponentsAndroid
Labelsqe-3.2.0
ReporterParas Mishra
AssigneeSunila
Created2013-11-28T06:52:41.000+0000
Updated2017-03-28T21:19:52.000+0000

Description

Android: Media: Unable to switch to front camera Issue occurs on SDK: 3.1.3.GA as well. Steps to reproduce: 1. Run the below app.
var win = Ti.UI.createWindow({
	backgroundColor:'white',
	layout:'vertical'
}); 
	// create button, register the modified click callback, add button to window
		function addButton(title, clickCallback)
		{
			var button = Ti.UI.createButton({title:title, width:'300', height:'50'});
			
			button.addEventListener('click', function() {
				Ti.Media.showCamera({mediaType:Ti.Media.MEDIA_TYPE_PHOTO});
				clickCallback();
				Ti.Media.vibrate();
				});
				
			win.add(button);
		}
		
		// camera with no switch
		addButton('Default Camera', function(){
			
		});
		
		// camera with front specified
		addButton('Front Camera Test 1', function(){
			Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
		});
		
		// camera with front specified after switching to back
		// checks if switch function actually works, opposed to it being the default
		addButton('Front Camera Test 2', function(){
			Ti.Media.switchCamera(Ti.Media.CAMERA_REAR);
			Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
		});
		
		// camera with back specified
		addButton('Back Camera Test 1', function(){
			Ti.Media.switchCamera(Ti.Media.CAMERA_REAR);
		});
		
		// camera with back specified after switching to front
		// checks if switch function actually works, opposed to it being the default
		addButton('Back Camera Test 2', function(){
			Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
			Ti.Media.switchCamera(Ti.Media.CAMERA_REAR);
		});
		
		// camera passed invalid (non-existent) argument
		addButton('Invalid Camera', function(){
			Ti.Media.switchCamera(undefined);
		});
		
	
		win.open();

2. Click 'Front Camera Test 1' Expected: Front Camera should be open. Actual: Unable to switch, front camera is opened. Logs occurs as " [ERROR] : TiMedia: (KrollRuntimeThread) [14139,14139] Camera preview is not open, unable to switch camera. [ERROR] : TiMedia: (KrollRuntimeThread) [1,14140] Camera preview is not open, unable to switch camera. [WARN] : IInputConnectionWrapper: showStatusIcon on inactive InputConnection [WARN] : IInputConnectionWrapper: showStatusIcon on inactive InputConnection [ERROR] : TiMedia: (KrollRuntimeThread) [13464,27604] Camera preview is not open, unable to switch camera. [WARN] : IInputConnectionWrapper: showStatusIcon on inactive InputConnection "

Comments

  1. Michael Gangolf 2013-11-28

    actually switching is working if you add an overlay with a button and switch after the camera is open. But you can't start directly with the front facing camera. Verified on Nexus 4 (3.2 Beta)
  2. Sunila 2013-12-03

    Camera can be switched only with custom overlay. With custom overlay, one can set 'whichCamera' option in the 'showCamera' options to set the default type.
  3. Lee Morris 2017-03-28

    Closing ticket as invalid.

JSON Source