-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseperated.html
73 lines (58 loc) · 1.64 KB
/
seperated.html
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
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<title>Video Player</title>
<style>
.vlplay {
width: 100%;
}
</style>
</head>
<body>
<video controls muted class="vlplay" poster="assets/poster.avif">
<source src="assets/hatav1-720.mp4" type='video/mp4' label='144p' res='144' />
<audio src="assets/test.mp3" type='audio/mp3' srclang="en" />
</video>
<button onclick="playVideoAndAudio()">Play</button>
<button onclick="pauseVA()">Pause</button>
<script>
var video = document.querySelector('.vlplay');
/*var audio = document.createElement('audio');
audio.src = 'assets/test.mp3';
audio.type = 'audio/mp3';
audio.preload = 'auto';
audio.controls = true;*/
//audio.style.display = 'none';
//video.parentNode.insertBefore(audio, video.nextSibling);
const sourceElements = video.querySelectorAll('audio');
if (sourceElements.length <= 1) {
//restrack.style.display = 'none'; // there is nothing to change
console.log("err");
}
</script>
<script>
video = document.querySelector('.vlplay');
audio = document.querySelector('audio');
video.load();
audio.load();
function playVideoAndAudio() {
video.play();
audio.play();
video.currentTime = 0;
audio.currentTime = 0;
}
video.addEventListener('seeked', function() {
audio.currentTime = video.currentTime;
console.log(audio.currentTime);
});
video.addEventListener('play', function() {
audio.currentTime = video.currentTime;
console.log(audio.currentTime);
}); video.addEventListener('paused', pauseVA());
function pauseVA() {
video.pause();
audio.pause();
};
</script>
</body>
</html>