-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
33 lines (25 loc) · 922 Bytes
/
script.js
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
var curSong = "";
function togglePlay(song) {
if (curSong != song) {
var audioElement = document.getElementById('aud');
var name = 'audio/' + song + '.mp3';
audioElement.setAttribute('src', name);
audioElement.setAttribute('autoplay', 'autoplay');
curSong = song;
audioElement.addEventListener("timeupdate", function() {
var currentTime = audioElement.currentTime;
var duration = audioElement.duration;
$('.hp_range').stop(true,true).animate({'width':(currentTime +.25)/duration*100+'%'},250,'linear');
});
}
$.get();
audioElement.addEventListener("load", function() {
audioElement.play();
}, true);
$('.play').click(function() {
audioElement.play();
});
$('.pause').click(function() {
audioElement.pause();
});
};