Adobe-Runtime-Support icon indicating copy to clipboard operation
Adobe-Runtime-Support copied to clipboard

[Android] Video stop working on input device connection/disconnection

Open itlancer opened this issue 2 years ago • 2 comments

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): https://github.com/airsdk/Adobe-Runtime-Support/issues/2017 https://github.com/airsdk/Adobe-Runtime-Support/issues/1939 https://github.com/airsdk/Adobe-Runtime-Support/issues/1194 https://github.com/airsdk/Adobe-Runtime-Support/issues/1003 https://github.com/airsdk/Adobe-Runtime-Support/discussions/706 https://github.com/airsdk/Adobe-Runtime-Support/issues/365 https://github.com/airsdk/Adobe-Runtime-Support/issues/155 https://github.com/airsdk/Adobe-Runtime-Support/issues/151 https://github.com/airsdk/Adobe-Runtime-Support/issues/87 https://github.com/airsdk/Adobe-Runtime-Support/issues/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 avatar Jan 04 '23 10:01 itlancer

Issue still exists with latest AIR 50.2.4.1.

itlancer avatar Nov 23 '23 13:11 itlancer

Issue still exists with latest AIR 51.1.1.5.

itlancer avatar Sep 23 '24 11:09 itlancer