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] Video stop working on input device connection/disconnection #2396

Open
itlancer opened this issue Jan 4, 2023 · 2 comments
Open
Labels

Comments

@itlancer
Copy link

itlancer commented Jan 4, 2023

Problem Description

Video stop working on input device connection/disconnection to Android device.
It happens only with AIR applications and completely break video playback until application will be restarted.

Tested with multiple AIR versions, even with latest AIR 50.1.1.2 with multiple different Android devices with different OS versions and architectures with different videos with different input devices.
Same problem in all cases. Bluetooth devices, USB devices, keyboards, mouses, remote controllers.
The same problem using Video, StageVideo and VideoTexture.
It works fine with non-AIR applications.
There is no such issue with USB cameras or headphones.
There is no such issue with Windows/macOS devices.
<disableMediaCodec>true</disableMediaCodec> didn't help.

Related issues (not the same):
#2017
#1939
#1194
#1003
#706
#365
#155
#151
#87
#6

Steps to Reproduce

  1. Launch application with code below with any Android device.
  2. Plug in or unplug input device (keyboard, mouse, remote controller) via USB or Bluetooth to Android device.

Application example with sources and example of video attached.
android_video_input_device_bug.zip

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.media.Video;
	import flash.events.NetStatusEvent;
	
	public class AndroidVideoInputDeviceBug extends Sprite {
		private var nc:NetConnection;
		private var ns:NetStream;
		private var video:Video;
		
		public function AndroidVideoInputDeviceBug() {
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			startVideo();
		}
	
		private function startVideo():void {
			removeChildren();
			
			if (ns != null){
				video.attachNetStream(null);
				ns.removeEventListener(NetStatusEvent.NET_STATUS, nsHandler);
				ns.dispose();
			}
		
			if (video != null){
				video.clear();
			}
			
			video = new Video(640, 480);
			addChild(video);
			
			if (nc != null){
				nc.removeEventListener(NetStatusEvent.NET_STATUS, ncHandler);
				nc.close();
			}
			
			nc = new NetConnection();
			nc.addEventListener(NetStatusEvent.NET_STATUS, ncHandler);
			nc.connect(null);
		}
		
		private function ncHandler(e:NetStatusEvent):void {
			if (e.info.code == "NetConnection.Connect.Success"){
				ns = new NetStream(nc);
				ns.checkPolicyFile = false;
				ns.client = {onMetaData:getMeta};
				ns.addEventListener(NetStatusEvent.NET_STATUS, nsHandler);
				
				video.attachNetStream(ns);
				ns.play("video.mp4");
			}
		}

		private function nsHandler(e:NetStatusEvent):void {
			trace(e.info.code);
			if (e.info.code == "NetStream.Play.Stop"){
				startVideo();
			}
		}

		private function getMeta(mdata:Object):void { }
	}
}

Actual Result:
No video anymore, just white screen. No any errors in NetStatusEvent

Expected Result:
Video will not be interrupted or stopped.

Known Workarounds

none

@itlancer
Copy link
Author

Issue still exists with latest AIR 50.2.4.1.

@itlancer
Copy link
Author

Issue still exists with latest AIR 51.1.1.5.

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