如何从React中的Blob对象播放音频? [英] How to play audio from blob object in React?
问题描述
我正在尝试使用ReactJS创建一个录音机应用程序.我使用npm软件包
您可以尝试使用此代码: https://www.npmjs.com/package/react-player
从文档中
class App扩展了组件{使成为 () {返回< ReactPlayer url ='<-您的BLOB->'播放/>}}
可以在此处找到更详细的示例-尚未测试,因为我必须将您的项目连接起来.但是看看您的blob mime类型,它是该库支持的webm.
I'm trying to create an audio recorder app using ReactJS. I used the npm package react-mic to serve the purpose. But the recordings were saved as a blob object.
How to play the recorded file (blob object) in the browser? And how to upload this as an audio file to online storage? (like firebase)
You could try using this: https://www.npmjs.com/package/react-player
From the docs:
class App extends Component {
render () {
return <ReactPlayer url='<--YOUR BLOB -->' playing />
}
}
And a more elaborate example can be found here - not tested though, as I would have to wire your project up. But looking at your blob mime-type, it's webm, which this library supports.
这篇关于如何从React中的Blob对象播放音频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!