I have a background-video (html5 video tag) overlayed by a "h 1" titel animated by jQuery. On Firefox and Chrome it works fine: video playback starts, and after every loop when the video restarts jQuery gets triggered by the video-event and restarts the titel-animation as well, so both video playback and video titel-text overlay are synchronized.
Unfortunately, on IE there is no titel-text displayed at all, and on Chrome the titel-text is displayed only on the first video-loop, as soon as the video starts the second loop there is no titel-text displayed anymore.
Here my code:
<div class="header-image-wrapper.wrap">
<h1 class="shadow" style="display: block; color: rgb(255, 255, 255);"></h1>
<p class="shadow" style="margin-top: 70px;"></p>
</div>
document.getElementById('bgvid').addEventListener('playing', myVideoHandler, false);
function myVideoHandler(e) {
const $this = $('div.header-image-wrapper.wrao h1');
const $span = $('div.header-image-wrapper.wrap h1 span');
$this.delay(700)
.fadeOut(0, () => {
$this.html('Text000000000000000000');
$this.css("color", "#fff");
})
.fadeIn(500)
.delay(8500)
/*.fadeOut(0)
.fadeIn(500, () => {
$this.html('Text1111111<br>Text1111111111');
})
.delay(5000) */
.fadeOut(500, () => {
$this.html('Text222222222');
$this.css("color", "#fff");
})
.fadeIn(500)
.fadeOut(300, () => {
$this.html('');
$this.css("color", "#fff");
})
}
UPDATE/SOLUTION:
I managed to fix it myself. Basically, there were 2 issues here.
First, the above code is using ES6 (EcmaScript 6) which is not supported by IE, see here: Support for ES6 in Internet Explorer 11
I had to remove the new syntax for callbacks, e.g.:
.fadeIn(500, () => {
$this.html('Text1111111<br>Text1111111111');
})
and instead rewrote it the old way:
.fadeIn(500, function() {
$this.html('Text1111111<br>Text1111111111');
})
Another big problem was, that some browsers, Safari and IE, didn't really fire some of the video events (e.g. event "play") when the video was set to loop. So, I deactivated the looping by removing the "loop" data attribute in the tag. Then, I added the following jQuery code which waits for the video event "ended" and then restarts the video again. Now the video loops, as before, but because it is programmatically restarted everytime, it fires the "play" event everytime the loop starts. I needed this "play" event so be able to restart the video text overlay animation. This way, the video and the animated text overlay stay synchronized.
$("#bgvid").bind("play", function() {
myVideoHandler();
});
$("#bgvid").bind("ended", function() {
$("#bgvid").get(0).play();
});