From 9fe187effeaf4a2e6205e2f1f52b32b8823f4f10 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 14 Jul 2014 15:21:12 -0400 Subject: muting, autoplay, loop --- public/assets/javascripts/mx/primitives/mx.video.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'public/assets/javascripts/mx/primitives/mx.video.js') diff --git a/public/assets/javascripts/mx/primitives/mx.video.js b/public/assets/javascripts/mx/primitives/mx.video.js index f92fe9f..c5dd749 100644 --- a/public/assets/javascripts/mx/primitives/mx.video.js +++ b/public/assets/javascripts/mx/primitives/mx.video.js @@ -30,6 +30,7 @@ MX.Video = MX.Object3D.extend({ this.player = document.createElement('video') this.player.addEventListener("loadedmetadata", this.ready.bind(this)) this.player.addEventListener("error", this.error.bind(this)) + this.player.addEventListener("ended", this.finished.bind(this)) this.player.width = this.width this.player.height = this.height this.player.src = this.media.url @@ -68,13 +69,25 @@ MX.Video = MX.Object3D.extend({ this.player.currentTime = n }, + mute: function(){ + this.player.muted = true + }, + + unmute: function(){ + this.player.muted = false + }, + duration: function(){ return this.player.duration }, finished: function(){ console.log("video finished") - if (this.media.bound) { + if (this.media.loop) { + this.seek(0) + this.play() + } + else if (this.bound) { $(".playButton").removeClass('playing') } }, -- cgit v1.2.3-70-g09d2