diff options
Diffstat (limited to 'public/assets/javascripts/mx/primitives/mx.video.js')
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.video.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/public/assets/javascripts/mx/primitives/mx.video.js b/public/assets/javascripts/mx/primitives/mx.video.js index 12d3dcb..53ccf2e 100644 --- a/public/assets/javascripts/mx/primitives/mx.video.js +++ b/public/assets/javascripts/mx/primitives/mx.video.js @@ -21,6 +21,7 @@ MX.Video = MX.Object3D.extend({ this.el.classList.add("video") this.el.classList.add("mx-scenery") this.paused = !! this.media.autoplay + this.playing = false this.muted = app.muted || !! this.media.mute }, @@ -31,8 +32,8 @@ MX.Video = MX.Object3D.extend({ 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.width = "100%" + this.player.height = "100%" this.player.src = this.media.url this.player.load() @@ -45,6 +46,9 @@ MX.Video = MX.Object3D.extend({ if (this.media.mute) { this.mute() } + else { + this.unmute() + } if (this.media.autoplay) { this.play() @@ -57,11 +61,13 @@ MX.Video = MX.Object3D.extend({ play: function(){ this.paused = false + this.playing = true this.player.play() }, pause: function(){ this.paused = true + this.playing = false this.player.pause() }, @@ -74,14 +80,21 @@ MX.Video = MX.Object3D.extend({ mute: function(){ this.player.muted = true + this.player.volume = 0 this.muted = true }, unmute: function(){ this.player.muted = false + this.player.volume = 0.8 this.muted = false }, + setVolume: function(n){ + if (this.muted || ! this.player) return + this.player.volume = n + }, + setLoop: function(state){ this.media.loop = state }, |
