currentTime не задает время? когда я указываю .currentTime=0;
И еще- у одной песни .duration показывает, а у другой выдает infinity/
Вот код:
$(function(){
music_count=0;
function duration_min_sec(sec){
minutes=Math.floor(sec/60);
seconds=Math.floor(sec-(minutes*60));
if(seconds<10) seconds="0"+seconds;
if(minutes<10) minutes="0"+minutes;
return minutes+" : "+seconds;
}
$("div.player div.controls span").click(function(){
controls_btn=$(this).attr("id");
switch (controls_btn){
case "play":
music[music_count].play();
$("#length").html(duration_min_sec(music[music_count].duration));
$("div.player div.controls span#play").css({'visibility':'hidden'});
$("div.player div.controls span#pause").css({'visibility':'visible'});
break;
case "pause":
music[music_count].pause();
$("div.player div.controls span#play").css({'visibility':'visible'});
$("div.player div.controls span#pause").css({'visibility':'hidden'});
break;
case "stop":
music[music_count].pause(); /////вот тут
music[music_count].currentTime=0;
//music[music_count].load();
$("div.player div.controls span#play").css({'visibility':'visible'});
$("div.player div.controls span#pause").css({'visibility':'hidden'});
break;
case "vol_up":
music[music_count].volume+=0.1;
break;
case "vol_down":
music[music_count].volume-=0.1;
break;
case "back":
if(music[music_count].playbackRate>1)
music[music_count].playbackRate=1;
else
music[music_count].playbackRate-=0.1;
break;
case "forward":
if(music[music_count].playbackRate<1)
music[music_count].playbackRate=1;
else
music[music_count].playbackRate+=0.1;
break;
}
$('input[type="range"]').change(function(){
music[music_count].volume=$('input[type="range"]').val()/10;
});
});
music[music_count].addEventListener('ended',function(){
music[music_count].pause();
music[music_count].currentTime=0;
music_count++;
if(music_count>music.length-1) music_count=0;
//alert(music_count);
music[music_count].play();
$('#sound_num').html(music_count+1);
});
function current_pl(){
$('#place').html(duration_min_sec(music[music_count].currentTime));
}
setInterval(current_pl,100);
});