Reputation: 580
Issue: changing source element of HTML5 video through jQuery throws error in IE9
This is my jQuery function to change the video source:
var hdswipe = function(){
var currVid, currExt, currVidName, currQuality, i, tempExt;
if($hdVideo.attr('paused')==false)
playerstage=1;
currVid = $hdVideo[0].currentSrc;
currExt = currVid.substr(currVid.lastIndexOf('.') + 1);
for(i=0; i<videoAttr.quality.length; i++) //Get current video quality
if(currVid == videoAttr.src[i])
currQuality=videoAttr.quality[i];
for(i=0; i<videoAttr.quality.length; i++) //Swipe the Video
{
tempExt = videoAttr.src[i].substr(videoAttr.src[i].lastIndexOf('.') + 1);
if((currExt==tempExt)&&(currQuality!= videoAttr.quality[i]))
{
$hdVideo.attr('src', videoAttr.src[i]);
createSeek();
createBuffer();
playerstage=0;
gPlay();
break;
}
}
if(currQuality == "sd")
$("a.hd-hd-swipe-button").addClass("hd-hd-swipe-button-hd");
else
$("a.hd-hd-swipe-button").removeClass("hd-hd-swipe-button-hd");
return false;
}
Error message shows up in IE9, when this line get executed:
$hdVideo.attr('src', videoAttr.src[i]);
The error message is:
Undefined Function in: $hdVideo.attr('buffered').end(0);
But the buffering function works fine since I play the video till the "hdswipe" function get called.
Please solve my problem.
Upvotes: 0
Views: 347
Reputation: 16027
I guess you should try using this syntax:
$hdVideo[0].buffered.end(0);
Upvotes: 1