我的 Safari 桌面有问题。这段代码甚至可以在 Safari 的移动版本上运行,但不能在桌面版本 (12.1) 上运行。
js
var targetBeep = "targetBeep";
var atmos = "atmos";
createjs.Sound.registerSound("targetBeep.mp3", targetBeep);
createjs.Sound.registerSound("25372639_dark-tension-atmosphere_by_umcsound_preview.mp3", atmos);
$( ".play" ).css({'cursor': 'pointer'}).click(function() {
setTimeout(function () {
createjs.Sound.play(atmos);
}, 2000);
});
HTML
<div class="play">
play
</div>
<script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>
<script src="https://code.createjs.com/1.0.0/createjs.min.js"></script>
是代码有问题还是 Safari 桌面有问题?如果是 Safari,我该怎么做才能解决这个问题
var atmos = "atmos";
createjs.Sound.registerSound("https://upload.wikimedia.org/wikipedia/commons/1/12/03may2020-tobefree.mp3", atmos);
$(".play").css({
'cursor': 'pointer'
}).click(function() {
setTimeout(function() {
createjs.Sound.play(atmos);
}, 2000);
});
<div class="play">
play
</div>
<script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>
<script src="https://code.createjs.com/1.0.0/createjs.min.js"></script>