So what I am trying to to is load different video based on the screen size of the device.
Here is my jQuery:
var v = new Array();
v[0] = [
"header.webm",
"header.ogv",
"header.mp4"
];
v[1] = [
"mobHead.webm",
"mobHead.ogv",
"mobHead.mp4"
];
var src = $('#bgvid source');
if(window.innerWidth >= 642){
src.attr("src", v[0]);
}
if(window.innerWidth <= 641){
src.attr("src", v[1]);
}
Here is my HTML:
<video autoplay="" loop="" poster="" id="bgvid">
<source src="" type="video/webm">
<source src="" type="video/ogg">
<source src="" type="video/mp4">
</video>
Here is the browser output:
<video autoplay="" loop="" poster="" id="bgvid">
<source src="header.webm,header.ogv,header.mp4" type="video/webm">
<source src="header.webm,header.ogv,header.mp4" type="video/ogg">
<source src="header.webm,header.ogv,header.mp4" type="video/mp4">
</video>
You can see where the problem lies. I need it to load them into the proper cascading order and not load them all into the same section.
How can I do this?