jQuery Simple Example
HTML
<script src="//www.addressfinder.co.nz/assets/v2/widget.js"></script>
<video id="video" width="200" height="200" controls>
<source id='currentVID' src="" type="video/mp4">
</video>
CSS
video.loading {
background: black url(http://blog.teamtreehouse.com/wp-content/uploads/2015/05/InternetSlowdown_Day.gif) center center no-repeat;
}
JavaScript
var actualvideo = 'https://api-files.sproutvideo.com/file/7c9adbb51915e2cdf4/b6e4822661adad1aremovethis/240.mp4';
if (actualvideo !== '') {
var video = document.getElementById('video');
var retry = 0;
$('video source').on('error', function() {
if(retry < 4){
retry++;
alert('something went wrong! Retrying.. '+retry+'');
$n = $(this);
setTimeout(function(){
$n.appendTo( $('#video') );
},5000);
}
});
video.pause();
var source = document.getElementById('currentVID');
source.setAttribute('src', actualvideo);
video.appendChild(source);
}