84669 人學習
152542 人學習
20005 人學習
5487 人學習
7821 人學習
359900 人學習
3350 人學習
180660 人學習
48569 人學習
18603 人學習
40936 人學習
1549 人學習
1183 人學習
32909 人學習
做h5小遊戲,需要長按按鈕放開後播放一個音效
GameStart.addEventListener('touchend', function(event) { event.preventDefault(); Audio.play(); }, false);
IOS的機制是必須透過使用者手動觸發, 可是我這應該也算才對吧?很是不明白,用touchstart則可以正常播放,希望大神能講解下,或者有什麼方案可以解決我這個需求,長按按鈕放開後再播放音效
Note: On iOS, the Web Audio API requires sounds to be triggered from an explicituser action, such as a tap. Calling noteOn() from an onload event will not play sound.
我搜了半天也沒找到蘋果關於user action的確切定義,可能touchend不屬於user action就目前嘗試,click與touchstart是可行的
你可以嘗試在touchstart時執行Audio.load(),在touchend是再執行Audio.play();
這個方法喲,解決了!
Note: On iOS, the Web Audio API requires sounds to be triggered from an explicituser action, such as a tap. Calling noteOn() from an onload event will not play sound.
我搜了半天也沒找到蘋果關於user action的確切定義,可能touchend不屬於user action
就目前嘗試,click與touchstart是可行的
你可以嘗試在touchstart時執行Audio.load(),在touchend是再執行Audio.play();
這個方法喲,解決了!