diff options
Diffstat (limited to 'assets/javascripts/mx/primitives/mx.video.js')
| -rw-r--r-- | assets/javascripts/mx/primitives/mx.video.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/assets/javascripts/mx/primitives/mx.video.js b/assets/javascripts/mx/primitives/mx.video.js new file mode 100644 index 0000000..b48eff3 --- /dev/null +++ b/assets/javascripts/mx/primitives/mx.video.js @@ -0,0 +1,48 @@ +MX.Video = MX.Object3D.extend({ + init: function (ops) { + + this.type = "Video" + + if (ops.src) this.loadTexture(ops) + + this.children.forEach(function (c, i) { + if (ops.texture) { + } + else if (ops.classname) { + c.el.classList.add(ops.classname) + } + else { + } + c.el.style.backgroundRepeat = 'no-repeat' + }) + + this.dirty = true + this.updateChildren = true + this.update() + }, + + loadTexture: function(ops){ + var layer = this + var video = document.createElement('video') + video.setAttribute("autoplay", "") + video.setAttribute("loop", "") + video.setAttribute("muted", "muted") + video.addEventListener("loadedmetadata", function(){ + layer.width = video.videoWidth + layer.height = video.videoHeight + layer.x = ops.x || 0 + layer.y = ops.y || 0 + layer.z = ops.z || 0 + layer.scale = ops.scale || 1 + layer.el.appendChild(video) + layer.el.classList.add('video') + layer.dirty = true + layer.update() + minimap.update() + }) + video.src = ops.src + video.load() + } + +}) + |
