Running Video in HTML5

I’ve been trying to figure this out for awhile now. I’m updating the CHAOS Framework DisplayVideo class and everything works fine in Flash but it doesn’t work at all in Haxe. Maybe I’ve over looked something or did something wrong. Here is what’s in my project.xml file.

<haxedef name="webgl" if="html5" />
<haxedef name="Dcanvas" if="html5" />

I check the way I handle things in the code and it’s not to different from the other examples I’ve seen on this message board.

This is what I use to handle setting up the class

_video = new Video();
_background = Draw.Square(10, 10, 0xFFFFFF);
_connection = new NetConnection();
_connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

    addEventListener(Event.ADDED_TO_STAGE, onStageAdd, false, 0, true);
    
    addChild(_background);
    addChild(_video);

Once you call the load method like so:

_videoURL = value; _autoStart = autoStart;
	var isMediaServer : Bool = false;
	
	// Check to see if string is pointing to media server
	for (i in 0...protocolList.length)
	{
		if (Std.string(_videoURL).indexOf(protocolList[i]) != -1) 
			isMediaServer = true;
	}
	
	_callBack = callBack;
	
	// Force video connect after setting url
	_connection.connect(((isMediaServer)) ? _videoURL : null);

It sets the connection to null and then the netStatusHandler method is fired due to an event listener. In HTML5 it the stats message is “connectSuccess” but in Flash its “NetConnection.Connect.Success”. Then I get a black box and a ton of warnings in Chrome.

[.Offscreen-For-WebGL-049CAFB8]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering. (index):1 WebGL: too many errors, no more errors will be reported to the console for this context.

Thanks for the help guys, I can’t wait for the input and to get these changes into the CHAOS GitHub.

Could you see if the following works?

openfl create PlayingVideo
cd PlayingVideo
openfl test html5

When you run openfl create PlayingVideo where does it create the folder/files? I’m sorry I use FlashDevelop when creating stuff. So I have no clue how the command line stuff works.

I typed the following openfl create PlayingVideo C:_WORKING\HAXE\PlayingVideo It just says it couldn’t find sample

So you’re not able to play video at all with this warning or after some time it stop to work? I got same warning in Chrome but still able to play video. Unfortunately after few times it stop to work.

Chrome msg: WebGL: INVALID_VALUE: texImage2D: no video
and it point to Video.hx , line 178:

gl.texImage2D (gl.TEXTURE_2D, 0, internalFormat, format, gl.UNSIGNED_BYTE, __stream.__video);
			
1 Like

Yeah, I got the same problem as you now.

If it says it can’t find the sample, perhaps the haxelib “openfl-samples” needs to be updated. Let me know if you’re current, and I forgot to release a newer version with the sample :slight_smile:

If all else fails, try https://github.com/openfl/openfl-samples

1 Like

Yeah, it’s not letting me download the sample. It timeout at 87% even with the -notimeout applied to it. Maybe something is wrong with the file.

No, it’s not. Just my computer.

Maybe this could fix the problem.