Reputation: 13
I want to add a video
to a HTML page.
I want it to be loaded only if the user presses the play button, not directly from the beginning on.
For that I use preload="none"
.
On W3Schools they say that it is not supported on Internet explorer.
So when someone enters the page, what will he see then?
Does the video
load from the beginning on or doesn't he even see the video
(maybe just a black space or something)?
Upvotes: 1
Views: 280
Reputation: 60603
you can set poster
for video
tag
thanks, but I want the following: video should only load if user clicks on play (thats done with preload). BUT if preload is not supported, I want the video to load directly from the beginning on. is this possible?
Ok then you can remove the poster
and add:
document.getElementsByTagName('video')[0].play();
in each condition that will test if the user agent is Internet Explorer
/**
* detect IE
* returns version of IE or false, if browser is not Internet Explorer
*/
function detectIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10 or older => return version number
document.getElementsByTagName('video')[0].play();
}
var trident = ua.indexOf('Trident/');
if (trident > 0) {
// IE 11 => return version number
document.getElementsByTagName('video')[0].play();
}
var edge = ua.indexOf('Edge/');
if (edge > 0) {
// Edge (IE 12+) => return version number
document.getElementsByTagName('video')[0].play();
}
// other browser
return false;
}
//Call the function
detectIE();
<video width="480" preload="none" controls>
<source src="https://archive.org/download/WebmVp8Vorbis/webmvp8.webm" type="video/webm">
<source src="https://archive.org/download/WebmVp8Vorbis/webmvp8_512kb.mp4" type="video/mp4">
<source src="https://archive.org/download/WebmVp8Vorbis/webmvp8.ogv" type="video/ogg">
Your browser doesn't support HTML5 video tag.
</video>
Upvotes: 1