-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay_functions.js
61 lines (45 loc) · 1.45 KB
/
play_functions.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
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
/* play_functions.js
* Contains functions for video and audio playback.
*/
function play_audio(idx){
console.log("Play audio " + idx);
var audiofile = eventlist[idx][2];
audioplaying_idx = idx;
audio.src = "/cam/media/" + audiofile + ".flac";
audio.ontimeupdate = function() {playing_update_legend()};
audio.onended = function() {
audioplaying = false;
audiostop_btn.hide();
draw();
}
audio.play();
audioplaying = true;
loading = true;
audiostop_btn.show();
}
function playing_update_legend(){
var start_x = pan + center_x + ((eventlist[audioplaying_idx][0] - centertimestamp) / secondsPerTile * imagewidth);
var legend_x = start_x + (audio.currentTime / secondsPerTile * imagewidth)
draw_spectrum_legend(legend_x);
if (audio.currentTime > 0.1) {
loading = false;
}
}
function playing_update_time_on_drag(x){
var start_x = pan + center_x + ((eventlist[audioplaying_idx][0] - centertimestamp) / secondsPerTile * imagewidth);
var difference_px = x - start_x;
var difference_sec = difference_px * secondsPerTile / imagewidth;
audio.currentTime = difference_sec;
}
function play_audio_stop(){
console.log("audio stop");
audio.pause();
audioplaying = false;
audiostop_btn.hide();
draw();
}
function play_video(idx){
modal.style.display = "block";
var videofile = eventlist[idx][2];
video.src = "/cam/media/" + videofile + ".mp4";
}