A. Howler.js為什麼有時候播放沒聲音
Howler.js默認使用Web Audio,但在IE上可以自動轉為HTML 5 Audio。這點很是貼心。
移動端的Safari和Chrome都禁止網頁自動播放聲音,必須通過用戶的操作,touch, click等觸發。Howler.js可以設置成自動捕捉用戶操作激活(解禁)聲音播放。
Howler.js支持很多聲音格式以兼容各種瀏覽器。MP3, MPEG, OPUS, OGG, OGA, WAV, AAC, CAF, M4A, MP4, WEBA, WEBM, DOLBY, FLAC.幾乎涵蓋了所有格式
支持3D游戲
自動緩存
B. 一款很好用的 Vue audio 插件 vue-audio-better
Type: String[] - Required
An array of audio file urls
Type: Boolean - Default: false
Whether to force HTML5 Audio
Type: Boolean - Default: false
Whether to start the playback again
automatically after it is done playing
Type: Boolean - Default: true
Whether to start downloading the audio
file when the component is mounted
Type: Boolean - Default: false
Whether to start the playback
when the component is mounted
Type: String[] - Default: []
Howler.js automatically detects your file format from the extension,
but you may also specify a format in situations where extraction won't work
(such as with a SoundCloud stream)
Type: Boolean - Default: false
Whether to enable the withCredentials flag on XHR requests
used to fetch audio files when using Web Audio API ( see reference )
Bundle the js to the dist folder:
howler.js
vue-howler
MIT