summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/mx/primitives/mx.vimeo.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/mx/primitives/mx.vimeo.js')
-rw-r--r--public/assets/javascripts/mx/primitives/mx.vimeo.js32
1 files changed, 25 insertions, 7 deletions
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')
}
}