diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-07-17 14:18:26 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-07-17 14:18:26 -0400 |
| commit | c175b8b78cad5424f81370e721277b18af6aff92 (patch) | |
| tree | 18d52ab439b4afb91e454d303ed4f45aee2602a0 /public/assets/javascripts/mx | |
| parent | 4ee827ad464dfa0edb664d27e5069811877deb1e (diff) | |
| parent | e5911a4760d62b803a166139835e661183850187 (diff) | |
merge
Diffstat (limited to 'public/assets/javascripts/mx')
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.video.js | 4 | ||||
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.vimeo.js | 32 | ||||
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.youtube.js | 20 |
3 files changed, 46 insertions, 10 deletions
diff --git a/public/assets/javascripts/mx/primitives/mx.video.js b/public/assets/javascripts/mx/primitives/mx.video.js index b28204d..cdb92c8 100644 --- a/public/assets/javascripts/mx/primitives/mx.video.js +++ b/public/assets/javascripts/mx/primitives/mx.video.js @@ -83,6 +83,10 @@ MX.Video = MX.Object3D.extend({ this.muted = false }, + setLoop: function(state){ + this.media.loop = state + }, + duration: function(){ return this.player.duration }, diff --git a/public/assets/javascripts/mx/primitives/mx.vimeo.js b/public/assets/javascripts/mx/primitives/mx.vimeo.js index 7a5327e..7bc0a26 100644 --- a/public/assets/javascripts/mx/primitives/mx.vimeo.js +++ b/public/assets/javascripts/mx/primitives/mx.vimeo.js @@ -21,15 +21,17 @@ MX.Vimeo = MX.Object3D.extend({ this.el.classList.add("video") this.paused = !! this.media.autoplay this.muted = app.muted || !! this.media.mute + this.started = false this.load() }, load: function (ops) { var uid = 'player-' + Uid () + var loop = this.media.loop ? 'loop=1' : "" var preload = document.createElement("iframe") preload.id = uid - preload.setAttribute("src", "//player.vimeo.com/video/" + this.media.token + "?api=1&badge=0&controls=0branding=0&byline=0&player_id=" + uid) + preload.setAttribute("src", "//player.vimeo.com/video/" + this.media.token + "?api=1&badge=0&controls=0branding=0&byline=0&portrait=0&title=0&" + loop + "&player_id=" + uid) preload.style.backgroundImage = "url(" + this.media.thumbnail + ")" preload.style.width = this.media.width + "px" preload.style.height = this.media.height + "px" @@ -44,6 +46,7 @@ MX.Vimeo = MX.Object3D.extend({ ready: function(){ console.log("vimeo ready") + this.started = true // wait until ready before binding events. other events: play, pause this.player.addEvent('play', this.onPlay.bind(this)) @@ -65,6 +68,9 @@ MX.Vimeo = MX.Object3D.extend({ if (this.media.autoplay) { this.play() } + else { + this.pause() + } }, error: function(err){ @@ -90,6 +96,11 @@ MX.Vimeo = MX.Object3D.extend({ return } + if (! this.started || n === 0) { + return + } + console.log("fukballz", n) + if (n < 1) { n = n * this.duration() } @@ -97,9 +108,10 @@ MX.Vimeo = MX.Object3D.extend({ if (this.paused) { this.paused = false this.play() + this.pause() setTimeout(function(){ this.pause() - }.bind(this), 1000) + }.bind(this), 100) } }, @@ -117,6 +129,11 @@ MX.Vimeo = MX.Object3D.extend({ this.muted = false }, + setLoop: function(state){ + this.media.loop = state + this.player.api('setLoop', state) + }, + onPlay: function(){ if (this.paused) { this.pause() @@ -130,11 +147,12 @@ MX.Vimeo = MX.Object3D.extend({ }, finished: function(){ - if (this.media.loop) { - this.seek(0) - this.play() - } - else if (this.bound) { +// if (this.media.loop) { +// this.seek(0) +// this.play() +// } +// else if (this.bound) { + if (! this.media.loop && this.bound) { $(".playButton").removeClass('playing') } } diff --git a/public/assets/javascripts/mx/primitives/mx.youtube.js b/public/assets/javascripts/mx/primitives/mx.youtube.js index 47d5507..5514359 100644 --- a/public/assets/javascripts/mx/primitives/mx.youtube.js +++ b/public/assets/javascripts/mx/primitives/mx.youtube.js @@ -31,6 +31,7 @@ MX.Youtube = MX.Object3D.extend({ var preload = document.createElement("div") preload.id = uid preload.style.backgroundImage = "url(" + this.media.thumbnail + ")" + preload.style.backgroundSize = "cover" preload.style.width = this.media.width + "px" preload.style.height = this.media.height + "px" preload.style.pointerEvents = "none" @@ -47,7 +48,11 @@ MX.Youtube = MX.Object3D.extend({ }.bind(this), 300) } else { - this.build(uid) + // not sure why i need to wait here.. + // stopped working until i added the setTimeout + setTimeout(function(){ + this.build(uid) + }.bind(this), 20) } }, @@ -67,6 +72,7 @@ MX.Youtube = MX.Object3D.extend({ disablekb: 1, controls: 0, enablejsapi: 1, + origin: window.location.origin, fs: 0, modestbranding: 1, iv_load_policy: 3, // no annotations @@ -84,6 +90,9 @@ MX.Youtube = MX.Object3D.extend({ if (this.media.autoplay) { this.play() } + else { + this.pause() + } if (this.media.mute) { this.mute() @@ -123,6 +132,7 @@ MX.Youtube = MX.Object3D.extend({ }, pause: function(){ + console.log(this, bzbz = this.player) this.paused = true this.player.pauseVideo() }, @@ -150,7 +160,11 @@ MX.Youtube = MX.Object3D.extend({ this.muted = false }, - finished: function(){ + setLoop: function(state){ + this.media.loop = state + }, + + finished: function(){ console.log("youtube finished") if (this.media.loop) { this.seek(0) @@ -164,5 +178,5 @@ MX.Youtube = MX.Object3D.extend({ }) window.onYouTubePlayerAPIReady = function(){ - // console.log("youtube api ready") + // console.log("youtube api ready") } |
