简体   繁体   中英

html5 video onsuspend, onerror attributes not working

I have a strange issue I cannot resolve with regards to video playback using html 5 controls specifically with chrome. I have 2 streams audio & video (each one with a different duration as the sound ends 10 seconds earlier), and got it pretty much working to sync and sync with seeking using the video seek bar.

If a video of type x-msvideo is attempted to playback, I expect chrome will not playback and that is exactly what happens (video control grays out as well) but I need to have the onerror function fire in order to ensure the audio does not play. In fact the onplay attribute still gets implemented. But it does not fire onError, and the onsuspend function fires regardless of type so I cannot use that either. Any suggestions on how to catch this occurrence. I cannot access the response content type either.

    vid.onerror = function() {
       aud.style.visibility = "hidden";
       aud.preload="none";
       vid.style.visibility = "hidden";
       aud.pause();
    }


    vid.onplay= function() {
            vid.style.visibility = "visible";
            vid.controls = true;
            if(!aud.ended && vid.currentTime <= aud.duration){
                aud.style.visibility = "visible";
                aud.controls = true;
                aud.play();
            }

Used the following work around for now:

    if (vid.readyState < 1) {
                aud.pause();
                return;
    }

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