summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/scenery
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/scenery')
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/_scenery.js1
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/move.js4
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/types/_object.js3
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/types/image.js1
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/types/video.js64
5 files changed, 71 insertions, 2 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js
index 74801e9..1493fc6 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js
@@ -19,6 +19,7 @@ var Scenery = new function(){
scene_media = new Scenery.types.image ({ media: media, wall: wall, id: id })
break
+ case 'video':
case 'youtube':
case 'vimeo':
scene_media = new Scenery.types.video ({ media: media, wall: wall, id: id })
diff --git a/public/assets/javascripts/rectangles/engine/scenery/move.js b/public/assets/javascripts/rectangles/engine/scenery/move.js
index bad0a55..94a4e52 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/move.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/move.js
@@ -26,6 +26,10 @@ Scenery.move = function(base){
Scenery.remove(base.id)
return
}
+
+ // load the modal
+ app.controller.pick(base)
+
if (! (editor.permissions.move || editor.permissions.resize) ) {
e.clickAccepted = false
return
diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js
index 05c760b..65f3a94 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js
@@ -35,6 +35,9 @@ Scenery.types.base = Fiber.extend(function(base){
destroy: function(){
this.unbind()
scene.remove(this.mx)
+ this.mx.media = null
+ this.mx.ops = null
+ this.mx = null
this.move = null
this.media = null
this.dimensions = null
diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/image.js b/public/assets/javascripts/rectangles/engine/scenery/types/image.js
index b668e6a..99c1810 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/types/image.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/types/image.js
@@ -17,6 +17,7 @@ Scenery.types.image = Scenery.types.base.extend(function(base){
this.mx = new MX.Image({
src: this.media.url,
scale: this.scale,
+ media: this.media,
y: this.scale * this.media.height/2,
backface: false,
})
diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/video.js b/public/assets/javascripts/rectangles/engine/scenery/types/video.js
index b34e55c..d3e2e76 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/types/video.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/types/video.js
@@ -14,13 +14,73 @@ Scenery.types.video = Scenery.types.base.extend(function(base){
},
build: function(){
- this.mx = new MX.Image({
- src: this.media.url,
+ switch (this.media.type) {
+ case 'video':
+ this.mxType = MX.Video
+ break
+ case 'vimeo':
+ this.mxType = MX.Vimeo
+ break
+ case 'youtube':
+ this.mxType = MX.Youtube
+ break
+ }
+ if (app.muted) {
+ this.media.mute = true
+ }
+ this.mx = new this.mxType({
+ media: this.media,
+ scale: this.scale,
y: this.scale * this.media.height/2,
backface: false,
})
scene.add( this.mx )
},
+
+ play: function(){
+ this.mx.play()
+ },
+
+ pause: function(){
+ this.mx.pause()
+ },
+
+ toggle: function(shouldPause){
+ if (typeof shouldPause !== "boolean") {
+ shouldPause = ! this.mx.paused
+ }
+ shouldPause ? this.mx.pause() : this.mx.play()
+ return shouldPause
+ },
+
+ toggleMuted: function(shouldMute){
+ if (typeof shouldMute !== "boolean") {
+ shouldMute = ! this.mx.muted
+ }
+ shouldMute ? this.mx.mute() : this.mx.unmute()
+ return shouldMute
+ },
+
+ paused: function(){
+ return this.mx.paused
+ },
+
+ muted: function(){
+ return this.mx.muted
+ },
+
+ seek: function(n){
+ this.mx.seek(n)
+ },
+
+ mute: function(muted){
+ if (muted) {
+ this.mx.mute()
+ }
+ else {
+ this.mx.unmute()
+ }
+ },
serialize: function(){
var data = base.serialize.call(this)