var idvar var pl var player var width var width2 function retard cnt p

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var idvar = 0;
var pl = [];
var player = 0;
var width = 0;
var width2 = 0;
function retard (cnt) {
player = document.getElementById(pl[cnt]);
if (player.paused) {
if (idvar != cnt && idvar != 0) {
playerOld = document.getElementById(pl[idvar]);
playerOld.ontimeupdate = function() {musicTime(playerOld.currentTime, cnt, 'p') };
playerOld.pause();
$('#pp'+idvar).toggleClass('play pause');
}
function playing(cnt) {
musicTime(player.currentTime, cnt, 'p');
width = (player.currentTime * 100) / player.duration;
$('#pr'+cnt).width(width+'%');
}
player.ontimeupdate = function() { playing(cnt); };
$('#pp'+cnt).toggleClass('play pause');
player.play();
player.addEventListener('ended', function () { nextTrack(cnt) });
player.addEventListener('progress', function () {
if (player.buffered.length > 0) {
var bufferedEnd = player.buffered.end(player.buffered.length - 1);
$('#ld'+cnt).width(((bufferedEnd*100)/player.duration)+'%');
}
});
idvar = cnt;
}
else {
if (idvar == cnt) {
player.pause();
$('#pp'+cnt).toggleClass('play pause');
idvar = 0;
}
}
/*player.addEventListener('progress', function () {
console.log(width2);
})*/
}
function nextTrack (cnt) {
if (pl[cnt++]) {
retard (cnt++);
}
else {
idvar = 0;
}
}
function musicTime (dur, cnt, type) {
var min = Math.floor(dur / 60);
dur = Math.round(dur - min * 60);
if (min < 10) {
min = '0'+min;
}
if (dur < 10) {
dur = '0'+dur;
}
$('#t'+type+cnt).html(min+':'+dur);
}