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

[Windows][macOS] StageVideo doesn't call onPlayStatus on playback complete #1943

Open
itlancer opened this issue May 30, 2022 · 4 comments
Open
Labels

Comments

@itlancer
Copy link

itlancer commented May 30, 2022

Problem Description

StageVideo doesn't call onPlayStatus on playback complete with Windows/macOS devices.
So you cannot handle onPlayStatus to play video in a loop or detect video playback end.

Tested with multiple AIR versions, even with latest AIR 33.1.1.856 with multiple different Windows/macOS devices with different OS versions with different MP4 H.264 videos.
Same problem in all cases.
The same issue with Windows for Video and with macOS for Video and VideoTexture.
It works with VideoTexture and Video.
For Windows It works with VideoTexture.

Also it works with iOS and Android.

Steps to Reproduce

Launch code below with any Windows/macOS device. After video playback it will be started again in a loop by handling onPlayStatus and NetStream::seek(0).

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

package {
	import flash.display.Sprite;
	import flash.events.NetStatusEvent;
	import flash.net.NetStream;
	import flash.net.NetConnection;
	import flash.media.StageVideo;
	import flash.geom.Rectangle;
	
	public class StageVideoOnPlayStatusBug extends Sprite {
		private var nc:NetConnection;
		private var ns:NetStream;
		
		public function StageVideoOnPlayStatusBug() {
			nc = new NetConnection();
			nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			nc.connect(null);
		}
		
		private function netStatusHandler(event:NetStatusEvent):void {
			trace(event.info.code);
			switch (event.info.code){
				case "NetConnection.Connect.Success":
					ns = new NetStream(nc);
					ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
					ns.client = {onMetaData:getMeta, onPlayStatus:onPlayStatus};
					var sv:StageVideo = stage.stageVideos[0];
					sv.viewPort = new Rectangle(0, 0, 720, 480);
					sv.attachNetStream(ns);
					ns.play("neon.mp4");
					break;
				case "NetStream.Play.StreamNotFound":
					trace("Stream not found");
					break;
			}
		}

		private function getMeta(mdata:Object):void {
			trace("metadata");
		}

		//This function doesn't call with Windows/macOS
		private function onPlayStatus(infoObject:Object):void {
			trace("onPlayStatus", infoObject.code);
			ns.seek(0);
		}
	}
}

Actual Result:
Video will be stopped after one playback. onPlayStatus method didn't called.

Expected Result:
Video playback in a loop. onPlayStatus method will be called.

Known Workarounds

Use NetStream.Play.Stop event to detect video playback end.

@itlancer itlancer added the Bug label May 30, 2022
@ajwfrost
Copy link
Collaborator

I've just changed:

var sv:StageVideo = stage.stageVideos[0];
sv.viewPort = new Rectangle(0, 0, 720, 480);
sv.attachNetStream(ns);

to

var vid:Video = new Video(720, 480);
addChild(vid);
vid.attachNetStream(ns);

but I still don't get the onPlayStatus callback... you mentioned that it works for you for Video?

@itlancer
Copy link
Author

@ajwfrost
Hm, seems my fault. Made retest and edit original post.
So, how video ending for me:
Windows:
Video - NetStream.Play.Stop
VideoTexture - onPlayStatus
StageVideo - NetStream.Play.Stop

macOS:
Video - NetStream.Play.Stop
VideoTexture - NetStream.Play.Stop
StageVideo - NetStream.Play.Stop

So seems with different platforms it has different behavior.

@ajwfrost
Copy link
Collaborator

ajwfrost commented Jun 1, 2022

Thanks .. so from what I can see, we should be both dispatching the NetStream.Play.Stop event via NetStatusEvent.NET_STATUS, and also calling the onPlayStatus method:
https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#event:onPlayStatus

onPlayStatus is also used for notifying of DRM-related activity and it may be that we've ended up with some 'normal' uses of it being removed when we disabled the DRM code.. we'll look to see where this should be dispatched (and how it's working with Windows + VideoTexture) and try to re-enable it across the board...

thanks

@itlancer
Copy link
Author

itlancer commented Jun 1, 2022

@ajwfrost
Great! May be some of that already outdated (legacy DRM-related methods). If it is so I think they should be removed and provide the same behavior/events/methods for different platforms in case of video playback.
I think even better if video complete event will be only handled via NetStream.Play.Stop for all platforms.

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

2 participants