HTML5 Audio files fail to load in Safari

前端 未结 2 1719
深忆病人
深忆病人 2021-01-05 07:49

[EDIT: using a simplified test page without Javascript etc.]

I\'ve got a webpage that contains four audio files. These files are served as HTML5

2条回答
  •  梦谈多话
    2021-01-05 08:19

    I was having a similar issue with files not loading and came up with this solution. It seems that HTML5 audio/video can "stall", meaning that is just stops loading. Luckily, there's a "stall" event that fires when this happens. What I did was listen for this event and when/if it fires, just try to force the audio to load again.

    Example using jQuery:

        // the event is 'onstalled' - 'stalled' in the jquery case
       $("audio").bind("stalled", function() { 
            var audio = this;
            audio.load();
    
            // Threw in these two lines for good measure.
            audio.play();
            audio.pause();
        });
    

提交回复
热议问题