This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('a.jump').live('click', function(event) { | |
event.preventDefault(); | |
var targetTime = $(this).attr('data-jump-target'); | |
player.api_play(); | |
player.api_seekTo(targetTime); | |
}); | |
// a typical link woul look like this, where the value in the data-jump-target is the time you want to jump to | |
<a href="#jump" class="jump" data-jump-target="455">Jump to 455</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add this after the '.sc-trackslist li' click listener | |
$(document).bind('activateTrack', function(event) { | |
var $track = $(event.target), | |
$player = $track.closest('.sc-player'), | |
trackId = $track.data('sc-track').id; | |
updateTrackInfo($player, trackId); | |
$track.addClass('active').siblings('li').removeClass('active'); | |
$('.artworks li', $player).each(function(index) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.sc-scrubber .sc-buffer, .sc-scrubber .sc-played { | |
width: 0; | |
-webkit-transition: width 1s linear; | |
-moz-transition: width 1s linear; | |
transition: width 1s linear; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SuperView = Backbone.View.extend({ | |
events: { | |
"click a.foo": "onFooClick" | |
}, | |
onFooClick: function(event) { | |
alert('onFooClick!'); | |
} | |
}); | |
var SubView = SuperView.extend({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// browser history with HTML5 support | |
(function() { | |
var loc = window.location, | |
pushSupport = !!(window.history && window.history.pushState), | |
hashStrip = /^#*/; | |
// add HTML5 support to Backbone.history, drop the old IE stuff | |
_.extend(Backbone.History.prototype, { | |
getFragment : function(l) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON("http://api.soundcloud.com/tracks?callback=?", | |
{ | |
consumer_key: YOUR_CONSUMERKEY, | |
format: "json" | |
}, | |
function(data) { | |
console.log("data from SoundCloud!", data); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<object height="81" width="80%"><param name="movie" value="http://player.soundcloud.com/player.swf?url={param}"></param><param name="allowscriptaccess" value="always"></param><embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url={param}" type="application/x-shockwave-flash" width="80%"></embed></object> <a href="{param}">{param}</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
// simple js string hashing | |
var simpleHash = function(s, tableSize) { | |
var i, hash = 0; | |
for (i = 0, l = s.length; i < l; i += 1) { | |
hash += (s[i].charCodeAt() * (i+1)); | |
} | |
return Math.abs(hash) % tableSize; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/ronniepollock/dysfunctional-tb303-dont-leave-me-tonight&g=bb"></param><param name="allowscriptaccess" value="always"></param><embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/ronniepollock/dysfunctional-tb303-dont-leave-me-tonight&g=bb" type="application/x-shockwave-flash" width="100%"></embed></object> <a href="http://soundcloud.com/ronniepollock/dysfunctional-tb303-dont-leave-me-tonight">[NAME]</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var positionInterval; | |
var startPolling = function(player) { | |
positionInterval = setInterval(function() { | |
var trackPosition = player.api_getTrackPosition(); | |
// do something with the trackPosition | |
}, 500); | |
}; | |
var stopPolling = function() { | |
clearInterval(positionInterval); | |
positionInterval = null; |