MX.Video = MX.Object3D.extend({ init: function (ops) { this.type = "Video" this.media = ops.media this.width = ops.media.width this.height = ops.media.height this.x = ops.x || 0 this.y = ops.y || 0 this.z = ops.z || 0 this.rotationX = ops.rotationX || 0 this.rotationY = ops.rotationY || 0 this.rotationZ = ops.rotationZ || 0 this.scale = ops.scale || 1 this.backface = ops.backface || false ops.className && this.el.classList.add(ops.className) this.backface && this.el.classList.add("backface-visible") this.el.classList.add("video") this.paused = true this.load() }, load: function(ops){ this.paused = true this.player = document.createElement('video') this.player.addEventListener("loadedmetadata", $.proxy(this.ready, this)) this.player.addEventListener("error", $.proxy(this.error, this)) this.player.width = this.width this.player.height = this.height this.player.src = this.media.url this.player.load() this.el.appendChild(this.player) }, ready: function(){ if (this.media.autoplay) { this.play() } else { this.player.currentTime = this.player.duration / 3 } }, error: function(err){ console.log("video error", err) }, play: function(){ this.paused = false this.player.play() }, pause: function(){ this.paused = true this.player.pause() }, seek: function(n){ this.player.currentTime = n }, duration: function(){ return this.player.duration }, finished: function(){ console.log("video finished") }, })