简体   繁体   中英

IE9 not playing updated video source which was injected through JQuery

I have developed one API for HTML5 Video. The specialty of the plugin is viewer can change the being played video. (Changing different source url through JQuery).

I almost done the task. But its not working in ie9. Let me share the source file here.

$hdVideo.attr('src', videoAttr.src[i]);
gPlay();
createSeek();
createBuffer();
playerstage=0;

the first line will inject the new source file to the video element. It works perfectly in all major browsers, except ie9. I couldn't even check the running html coding in ie9 (when we make some changes though js, its not get reflected in inspect element).

The link is at: http://iseofirm.net/appthateam/vel/static3/

I got the solution myself, finally!!!!!

Problem: IE9 indexes the first tag, even though we inject src="" into tag through jQuery

Solution: When the player starts, inject "src" value of first "source" element into tag.

if(firstTime)
    {
        $hdVideo.attr('src', videoAttr.src[0]);
        firstTime=0;
    }

Then write function to inject corresponding "source url" into tag's src="" attribute...

var hdswipe = function(){
            var currVid, currExt, currVidName, currQuality, i;
            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
            {
                if((currExt==videoAttr.src[i].substr(videoAttr.src[i].lastIndexOf('.') + 1))&&(currQuality!= videoAttr.quality[i]))
                {  
                    $hdVideo.attr('src', videoAttr.src[i]);
                    gPlay();
                    createSeek();
                    createBuffer();
                    playerstage=0;
                    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;
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM