1 // Javascript functions for controlling audio
19 // If endtime is not set then we can't loop
20 if (endtime == 0) return;
22 // if we're past the endtime then it's time to start back at the A marker
23 if (song.currentTime > endtime) song.currentTime = starttime;
26 window.onload = function() {
27 song = document.getElementById('song');
29 starttime = song.currentTime;
30 endtime = song.duration;
31 body = document.getElementsByTagName('body')[0]
35 interval = setInterval(loop, 1000);
41 if (ev.keyCode == spacebar) {
50 clearInterval(interval)
55 song.currentTime = starttime
59 interval = setInterval(loop, 1000);
67 } else if (ev.keyCode == return2start) {
68 if (starttime != null) {
69 song.currentTime = starttime;
75 } else if (ev.keyCode == leftarrow) {
76 song.currentTime -= howmanysecs;
80 } else if (ev.keyCode == rightarrow) {
81 song.currentTime += howmanysecs;
85 } else if (ev.keyCode == seta) {
86 // Reset endtime if setting a new A marker
87 if (endtime != song.duration) endtime = song.duration;
89 starttime = song.currentTime;
91 // Translate seconds to timecode
92 document.getElementById('a').innerHTML = Math.floor(starttime / 60) + ':' + Math.floor(starttime % 60);
95 } else if (ev.keyCode == setb) {
96 if (song.currentTime > starttime) {
97 endtime = song.currentTime;
98 document.getElementById('b').innerHTML = Math.floor(endtime / 60) + ':' + Math.floor(endtime % 60);
100 } else if (ev.keyCode == cleara) {
102 endtime = song.duration;
104 document.getElementById('a').innerHTML = '<font color=#666><i>not set</i></font>';
105 document.getElementById('b').innerHTML = '<font color=#666><i>not set</i></font>';
110 } // getElementByTagName