It fucking works. again.

This commit is contained in:
magnolia-fan 2011-04-15 01:19:58 +04:00
parent 5939bbff2c
commit 82f2624ed5

View File

@ -14,7 +14,6 @@ $(function(){
} }
}); });
}); });
audio = document.getElementsByTagName('audio')[0];
$('#player .play').click(function(){ $('#player .play').click(function(){
if (! audio.src) return; if (! audio.src) return;
audio.play(); audio.play();
@ -66,7 +65,7 @@ $(function(){
function updatePlayer() { function updatePlayer() {
duration = audio.duration; duration = audio.duration;
cur_time = audio.currentTime; cur_time = audio.currentTime;
if (cur_time == duration) { if (cur_time > 0 && cur_time == duration) {
playNext(); playNext();
} }
loaded = 0; loaded = 0;
@ -151,11 +150,12 @@ function addToPlaylist(artist, track, length, id) {
} }
function addAudio(id) { function addAudio(id) {
if ($('#audio_'+ id).length == 0) { if ($('#audio_'+ id).length == 0) {
$('#audiobox').append('<audio id="audio_'+ id +'" src="/listen/'+ id +'.mp3" preload="preload"></audio>'); $('#audiobox').append('<audio id="audio_'+ id +'" src="" preload="preload"></audio>');
$('#audio_'+ id).attr('src', '/listen/'+ id +'.mp3');
} }
} }
function switchAudio(id) { function switchAudio(id) {
if (audio) { if (typeof(audio) != 'undefined') {
audio.pause(); audio.pause();
audio.currentTime = 0; audio.currentTime = 0;
} }