// Class: openfl.display3D.textures.VideoTexture

var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this

$global.Object.defineProperty(exports, "__esModule", {value: true});

var __map_reserved = {};

// Imports

var $hxClasses = require("./../../../hxClasses_stub").default;
var $import = require("./../../../import_stub").default;
var $extend = require("./../../../extend_stub").default;
function openfl_display3D_textures_TextureBase() {return require("./../../../openfl/display3D/textures/TextureBase");}
function haxe_Timer() {return require("./../../../haxe/Timer");}
function openfl__$internal_stage3D_opengl_GLVideoTexture() {return require("./../../../openfl/_internal/stage3D/opengl/GLVideoTexture");}
function openfl_events_Event() {return require("./../../../openfl/events/Event");}

// Constructor

var VideoTexture = function(context) {
	(openfl_display3D_textures_TextureBase().default).call(this,context);
	(openfl__$internal_stage3D_opengl_GLVideoTexture().default).create(this,this.__context.__renderer);
}

// Meta

VideoTexture.__name__ = ["openfl","display3D","textures","VideoTexture"];
VideoTexture.__super__ = (openfl_display3D_textures_TextureBase().default);
VideoTexture.prototype = $extend((openfl_display3D_textures_TextureBase().default).prototype, {
	attachNetStream: function(netStream) {
		var _gthis = this;
		this.__netStream = netStream;
		if(this.__netStream.__video.readyState == 4) {
			(haxe_Timer().default).delay(function() {
				_gthis.__textureReady();
			},0);
		} else {
			this.__netStream.__video.addEventListener("canplay",function(_) {
				_gthis.__textureReady();
			},false);
		}
	},
	__getTexture: function() {
		return (openfl__$internal_stage3D_opengl_GLVideoTexture().default).getTexture(this,this.__context.__renderer);
	},
	__textureReady: function() {
		this.videoWidth = this.__netStream.__video.videoWidth;
		this.videoHeight = this.__netStream.__video.videoHeight;
		this.dispatchEvent(new (openfl_events_Event().default)("textureReady"));
	}
});
VideoTexture.prototype.__class__ = $hxClasses["openfl.display3D.textures.VideoTexture"] = VideoTexture;

// Init



// Statics




// Export

exports.default = VideoTexture;