This commit is contained in:
Trevor Squillario 2012-09-27 16:34:14 -04:00
parent 5ae986a08a
commit 42a6c85e46
10 changed files with 110 additions and 105 deletions

View file

@ -1,7 +1,7 @@
var scrobbled = false;
function playSong(el, songid, albumid) {
ajaxUrl = baseURL + '/getMusicDirectory.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp&id=' + albumid;
if (debug) { console.log(ajaxUrl) }
if (debug) { console.log(ajaxUrl) }
$.ajax({
url: ajaxUrl,
method: 'GET',
@ -50,9 +50,6 @@ function playSong(el, songid, albumid) {
$('#songdetails').css('visibility', 'visible');
// SoundManager Initialize
var salt = Math.floor(Math.random() * 100000);
if (audio) {
soundManager.destroySound('audio');
}
soundManager.onready(function () {
if (debug) {
console.log("SM HTML5 STATUS");
@ -60,19 +57,21 @@ function playSong(el, songid, albumid) {
console.log(key + ': ' + value);
});
}
audio = soundManager.createSound({
soundManager.destroySound('audio');
soundManager.createSound({
id: 'audio',
url: baseURL + '/stream.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&id=' + songid + '&salt=' + salt,
stream: true,
type: 'audio/mp3',
whileloading: function () {
if (debug) { console.log('loaded:' + this.bytesLoaded + ' total:' + this.bytesTotal); }
//if (debug) { console.log('loaded:' + this.bytesLoaded + ' total:' + this.bytesTotal); }
var percent = this.bytesLoaded / this.bytesTotal;
var scrubber = $('#audio_wrapper0').find(".scrubber");
var loaded = $('#audio_wrapper0').find(".loaded");
loaded.css('width', (scrubber.get(0).offsetWidth * percent) + 'px');
},
whileplaying: function () {
if (debug) { console.log('position:' + this.position + ' duration:' + this.duration); }
//if (debug) { console.log('position:' + this.position + ' duration:' + this.duration); }
var percent = this.position / this.duration;
var scrubber = $('#audio_wrapper0').find(".scrubber");
var progress = $('#audio_wrapper0').find(".progress");
@ -101,7 +100,7 @@ function playSong(el, songid, albumid) {
scrubber.click(function (e) {
var x = (e.pageX - this.offsetLeft) / scrubber.width();
var position = Math.round(dp * 1000 * x);
audio.play({
soundManager.play('audio', {
position: position
});
});
@ -111,7 +110,7 @@ function playSong(el, songid, albumid) {
changeTrack(next);
}
});
audio.play('audio');
soundManager.play('audio');
});
$('table.songlist tr.song').removeClass('playing');