summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine')
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/_scenery.js5
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/types/audio.js73
2 files changed, 78 insertions, 0 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js
index 436712a..a0f5b35 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js
@@ -27,6 +27,11 @@ var Scenery = new function(){
scene_media = new Scenery.types.video (opt)
break
+ case 'soundcloud':
+ if (is_mobile) return
+ scene_media = new Scenery.types.audio (opt)
+ break
+
case 'text':
scene_media = new Scenery.types.text (opt)
scene_media.focused = true
diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/audio.js b/public/assets/javascripts/rectangles/engine/scenery/types/audio.js
new file mode 100644
index 0000000..82f984e
--- /dev/null
+++ b/public/assets/javascripts/rectangles/engine/scenery/types/audio.js
@@ -0,0 +1,73 @@
+
+Scenery.types.audio = Scenery.types.base.extend(function(base){
+
+ var exports = {
+
+ type: 'audio',
+
+ init: function(opt){
+
+ opt.scale = 1.0
+
+ base.init.call(this, opt)
+
+ this.build()
+ this.bind()
+ this.place(opt)
+ },
+
+ build: function(){
+ this.mx = new MX.Soundcloud({
+ scale: this.scale,
+ media: this.media,
+ y: this.scale * this.media.height/2,
+ backface: false,
+ })
+ scene.add( this.mx )
+ this.mx.load()
+ },
+
+ serialize: function(){
+ var data = base.serialize.call(this)
+ return data
+ },
+
+ deserialize: function(data){
+ this.mx.move(data.position)
+ this.mx.ops.width = data.dimensions.a
+ this.mx.ops.height = data.dimensions.b
+ this.dimensions.deserialize(data.dimensions)
+ },
+
+ play: function(){
+ this.mx.play()
+ },
+
+ pause: function(){
+ this.mx.pause()
+ },
+
+ toggle: function(){
+ this.mx.toggle()
+ },
+
+ paused: function(){
+ return this.mx.paused
+ },
+
+ muted: function(){
+ return this.mx.muted
+ },
+
+ seek: function(n){
+ this.mx.seek(n)
+ },
+
+ setLoop: function(shouldLoop){
+ this.mx.setLoop(shouldLoop)
+ },
+
+ }
+
+ return exports
+})