HTML5 Audio tag on Safari has a delay

后端 未结 9 589
無奈伤痛
無奈伤痛 2020-11-27 18:50

I\'m trying to accomplish a simple doodle-like behaviour, where a mp3/ogg sound rings on click, using the html tag. It is supposed to work under Firefox, Safari and Safari

9条回答
  •  有刺的猬
    2020-11-27 19:18

    The problem with Safari is that it puts a request every time for the audio file being played. You can try creating an HTML5 cache manifest. Unfortunately my experience has been that you can only add to the cache one audio file at a time. A workaround might be to merge all your audio files sequentially into a single audio file, and start playing at a specific position depending on the sound needed. You can create an interval to track the current play position and pause it once it has reached a certain time stamp.

    Read more about creating an HTML5 cache manifest here:

    http://www.html5rocks.com/en/tutorials/appcache/beginner/

    http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html

    Hope it helps!

提交回复
热议问题