No ;
in sight
This commit is contained in:
parent
16be696f91
commit
af9028db95
1 changed files with 20 additions and 20 deletions
|
@ -27,16 +27,16 @@
|
|||
*/
|
||||
// https://gist.github.com/michancio/59b9f3dc54b3ff4f6a84
|
||||
// Find elements
|
||||
var SyncVideo = document.querySelector(".main-video");
|
||||
var SyncAudio = document.querySelector(".main-audio");
|
||||
var SyncVideo = document.querySelector(".main-video")
|
||||
var SyncAudio = document.querySelector(".main-audio")
|
||||
|
||||
// Object for synchronization of multiple media/sources
|
||||
if (typeof window.MediaController === "function") {
|
||||
var controller = new MediaController();
|
||||
SyncVideo.controller = controller;
|
||||
SyncAudio.controller = controller;
|
||||
var controller = new MediaController()
|
||||
SyncVideo.controller = controller
|
||||
SyncAudio.controller = controller
|
||||
} else {
|
||||
controller = null;
|
||||
controller = null
|
||||
}
|
||||
|
||||
// Run SyncAudio and SyncVideo simultaneously
|
||||
|
@ -44,49 +44,49 @@ SyncVideo.addEventListener(
|
|||
"play",
|
||||
function () {
|
||||
if (!controller && SyncAudio.paused) {
|
||||
SyncAudio.play();
|
||||
SyncAudio.play()
|
||||
}
|
||||
},
|
||||
false,
|
||||
);
|
||||
)
|
||||
|
||||
// Pause/Play and Buffering
|
||||
SyncVideo.addEventListener("waiting", () => {
|
||||
// If SyncVideo is buffering
|
||||
SyncAudio.pause();
|
||||
});
|
||||
SyncAudio.pause()
|
||||
})
|
||||
SyncVideo.addEventListener("playing", () => {
|
||||
// If SyncVideo is done buffering
|
||||
SyncAudio.play();
|
||||
SyncTimestamp();
|
||||
});
|
||||
SyncAudio.play()
|
||||
SyncTimestamp()
|
||||
})
|
||||
|
||||
SyncVideo.addEventListener(
|
||||
"pause",
|
||||
function () {
|
||||
if (!controller && !SyncAudio.paused) {
|
||||
SyncAudio.pause();
|
||||
SyncAudio.pause()
|
||||
}
|
||||
},
|
||||
false,
|
||||
);
|
||||
)
|
||||
|
||||
// When Media Ends
|
||||
SyncVideo.addEventListener(
|
||||
"ended",
|
||||
function () {
|
||||
if (controller) {
|
||||
controller.pause();
|
||||
controller.pause()
|
||||
} else {
|
||||
SyncVideo.pause();
|
||||
SyncAudio.pause();
|
||||
SyncVideo.pause()
|
||||
SyncAudio.pause()
|
||||
}
|
||||
},
|
||||
false,
|
||||
);
|
||||
)
|
||||
|
||||
// Seekbar
|
||||
function SyncTimestamp() {
|
||||
SyncAudio.currentTime = SyncVideo.currentTime;
|
||||
SyncAudio.currentTime = SyncVideo.currentTime
|
||||
}
|
||||
</script>
|
Loading…
Reference in a new issue