Skip to content

Commit

Permalink
add sound manager
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Aug 17, 2013
1 parent 067d81f commit 8daedea
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions app/scripts/data/sound.js
@@ -1,7 +1,8 @@
define([
"flight/component",
"jquery",
"scripts/util"
"scripts/util",
"soundmanager"
], function ( defineComponent, $ ) {
return defineComponent( sound )

Expand All @@ -16,7 +17,11 @@ define([
}

function soundCloudGet ( fly, data ) {
var audio = $( "<audio>" );
soundManager.setup({
url: "bower_components/soundmanager/swf/",
preferFlash: false,
debugMode: false
});
var request = {
// I have no idea why, but the api seems to return
// the same track every time unless I ask >1.
Expand All @@ -43,14 +48,21 @@ define([
type: 'sound',
userImage: track.user.avatar_url
}

fly.trigger( document, "dataSoundInfo", sanitised );

// load the audio up a bit before announcing i've got it
audio.attr( "src", sanitised.pieceLinkRaw )
// .append( "body" )
.on( "canplay", function () {
sanitised.element = audio.clone();
fly.trigger( document, "dataSound", sanitised );
soundManager.onready(function () {
sanitised.sound = soundManager.createSound({
url: sanitised.pieceLinkRaw,
autoLoad: true,
autoPlay: false,
onload: function () {
fly.trigger( document, "dataSound", sanitised );
},
onfinish: function () {
fly.trigger( document, "dataSoundOver", sanitised );
}
});
});
});
}
});
}});

0 comments on commit 8daedea

Please sign in to comment.