如何使用 next.js 导入 mp3 文件?
我正在尝试将 mp3 文件导入到我的 next.js 项目 -
我想从 AudioPlayer.js 访问文件“DRUMS.mp3”,所以我编写了
从以下位置导入鼓'../resources/DRUMS.mp3';
但这出现了:
我还安装了 - 'npm install file-loader --save-dev' 但这没有帮助。
感谢所有回复者!
I'm trying to import mp3 files to my next.js project -
I want to access the file 'DRUMS.mp3' from AudioPlayer.js so I wrote
import drums from '../resources/DRUMS.mp3';
but this comes up:
I've also installed - 'npm install file-loader --save-dev'
but that didn't help.
Thanks to all responders!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 html
audio
标签来播放它 - 将其放在公共文件夹中,然后直接引用它们,即如果您想进一步与音频 api 交互,您可以使用
webaudio
API - https://www.html5rocks.com/en/tutorials/webaudio/intro/You could just use an html
audio
tag to play it - place it in the public folder and then reference them directly, i.eIf you want to further interact with the audio api, you could use the
webaudio
API - https://www.html5rocks.com/en/tutorials/webaudio/intro/