首页 > 解决方案 > 音频未在 Howler.js 中播放

问题描述

我正在尝试通过 Howler 播放声音,但它不起作用。没有播放音频,控制台中也没有显示错误消息。代码如下所示。

var ngTest= new Howl({
    src:["https://www.newgrounds.com/audio/download/801982"]
    });

ngTest.play();

标签: javascripthtmlaudiohowler.js

解决方案


直播流或 MP3 URL 只能通过 HTML5 音频播放。

let file= new Howl({
        src: 'http://20423.live.streamtheworld.com/RADIO538.mp3',
        html5: true, // A live stream can only be played through HTML5 Audio.
        format: ['mp3', 'aac']
});

file.play();

推荐阅读