javascript - What's causing this slow/delayed audio playback in Safari? -
var audio = new audio('data:audio/wav;base64,uklgroabaabxqvzfzm10ibaaaaabaaeaibuaaigvaaabaagazgf0yvwbaachlqa1xnlg7vv/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////tk1lsklhrkveq0jbqd8+pj08pds6ojk5otg4odg3nzc3nzc3nzc3nzc3nzg4odg5otk6ojs7ozw8pt4+p0baqujcq0rfruzhseljsktmtu5ot1brulnuvvvwv1hzwltcxv1ex2bhymnkzgvmz2hpawprbg1ubm9wcxfyc3r0dxz3d3h5exp6e3x8fx1+f3+agigbgokcg4oehisfhywghoahh4ehh4iiiiiiiiiiiiiiiiiiiiiiiiiiiiehh4ehhoaghywfhiseg4ocgogbgia='); setinterval(function() { audio.play(); }, 50);
this code works correctly in chrome , firefox, in safari there's delay of on second between each sound. can't figure out why be, far can tell there no compatibility issues. want play sounds @ precise time , @ reasonably fast delay in game i'm making, how can working?
(copied the same question answered now)
safari displays curious behaviour when comes audio. seems like:
- with html5 audio tag, if audio less 500ms, volume in safari might fluctuate formats
- with html5 audio tag, delay obvious formats
- with flash audio player, delay obvious
*.wav
, it's fine*.mp3
considering on other platforms:
- ie9 doesn’t support native audio tag
- firefox’s audio sounds terrible when html5 audio tag used
mp3
/ogg
format, okaywav
. - firefox fine flash audio player
to achieve compatibility across browsers:
- use flash audio player
- use
mp3
,wav
format - put
mp3
beforewav
so sound manager 2:
soundmanager.setup({ url: './swf/', flashversion: 9, preferflash: true, onready: function() { soundmanager.createsound({ id: "button", url: ["./audio/button.mp3", "./audio/button.wav"], autoload: true, autoplay: false, volume: volume }); } });
and play with:
soundmanager.play("button");
this should solve delay issue safari.
Comments
Post a Comment