javascript - 音频未在 Howler.js 中播放
问题描述
我正在尝试通过 Howler 播放声音,但它不起作用。没有播放音频,控制台中也没有显示错误消息。代码如下所示。
var ngTest= new Howl({
src:["https://www.newgrounds.com/audio/download/801982"]
});
ngTest.play();
解决方案
直播流或 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();
推荐阅读
- c# - 除非附加了调试器,否则 ASP.NET Core ILogger 不会记录到 Trace
- python - 分片/模组功能
- java - 读取 Math.random 生成的按钮标签的值
- r - 在 r 中导入超过一个字节作为分隔符的文本文件
- ruby-on-rails - Ruby on Rails 和 Datatables.net
- python - 如何有效地将函数应用于大熊猫系列?
- asp.net-core - 菜单对齐 - 下拉菜单项与菜单项不一致
- c - 线程 1:EXC_BAD_ACCESS(代码=1,地址=0x800000012)
- sql - 在列中搜索部分文本
- haskell - 多态性的等级和(im)预测性之间有什么关系?