Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] scanHardware() doesn't work for Camera #1993

Open
itlancer opened this issue Jun 27, 2022 · 0 comments
Open

[Android] scanHardware() doesn't work for Camera #1993

itlancer opened this issue Jun 27, 2022 · 0 comments
Labels

Comments

@itlancer
Copy link

itlancer commented Jun 27, 2022

Problem Description

scanHardware() doesn't work for Camera with Android devices. Camera.names array not update.
So there is no way to connect/disconnect USB cameras in run-time. Camera.names returns correct data only after application restart.

Tested with multiple AIR versions, even with latest AIR 33.1.1.889 with multiple different Android devices with different OS versions with different USB cameras.
Same problem in all cases.
It works fine with non-AIR applications. For example in Chrome browser.
There is no such issue with Windows devices.
There is related issue with macOS devices: #1992

Didn't check the same for microphones.

Steps to Reproduce

  1. Launch code below with any Android device with connected USB cameras. Better to use Android TV Box to reproduce this issue.
  2. Click anywhere on stage, in Scout you will see trace with camera name (0): cameras: 0
  3. Unplug USB camera.
  4. Click anywhere on stage one more time. It will call scanHardware() and output Camera.names once again.

Application example with sources attached.
android_camera_scanhardware_bug.zip

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.media.Camera;
	import flash.events.MouseEvent;
	import flash.media.scanHardware;
	
	public class AndroidCameraScanHardwareBug extends Sprite {
		
		public function AndroidCameraScanHardwareBug() {
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			stage.addEventListener(MouseEvent.CLICK, click);
		}
	
		private function click(e:MouseEvent):void {
			scanHardware();
			
			trace("cameras:", Camera.names);
		}
	}
}

Actual Result:
In Scout you will see trace with unplugged camera: cameras: 0

Expected Result:
In Scout you will see trace without unplugged camera: cameras:

Known Workarounds

none
May be write own native extension for camera usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant