HTML5 Audio files fail to load in Safari

前端 未结 2 1658
深忆病人
深忆病人 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:17

    Looking at generated source of your page you load as first source an ogg file then a mp3 file in this exact order

    But, as specified in http://html5doctor.com/native-audio-in-the-browser/ file are in inverse order, so try to do the same

    otherwise try to serve in your sources also an aac audio in a m4a/mp4 container

    0 讨论(0)
  • 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();
        });
    
    0 讨论(0)
提交回复
热议问题