Skip to content

Commit

Permalink
Update javascript.js
Browse files Browse the repository at this point in the history
  • Loading branch information
willmyethewebsiteguy authored Aug 11, 2022
1 parent 9836450 commit c0a86eb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,20 @@
observer.observe(video) ;
}
} else if (videoObj.autoPlay == 'onLoad') {
setTimeout(function() {
video.addEventListener('canplay', (event) => {
video.muted = true;
video.setVolumeState();
video.playVideo();
el.setAttribute('data-video-state', 'playing');
}, 10);
// Show loading animation.
var playPromise = video.play();
if (playPromise == undefined) return;
playPromise.then(_ => {
video.setVolumeState();
video.playVideo();
el.setAttribute('data-video-state', 'playing');
}).catch(error => {
video.pauseVideo();
el.setAttribute('data-video-state', 'paused');
});
});
}

/*Set PlayBackRate*/
Expand Down Expand Up @@ -310,7 +318,7 @@
});

if(!document.querySelector('#wm-video-element-css')){
addCSSFileToHeader('https://cdn.jsdelivr.net/gh/willmyethewebsiteguy/VideoElement@1.2.004/styles.min.css');
addCSSFileToHeader('https://cdn.jsdelivr.net/gh/willmyethewebsiteguy/VideoElement@1.2.005/styles.min.css');
function addCSSFileToHeader(url) {
let head = document.getElementsByTagName('head')[0],
link = document.createElement('link');
Expand Down

0 comments on commit c0a86eb

Please sign in to comment.