每个人, 在React项目中使用waveurfer.js时遇到麻烦。 错误为:(未捕获(承诺)DOMException:无法解码音频数据) 这是我的代码:
import React, { Component } from 'react';
import WaveSurfer from 'wavesurfer.js';
import TimelinePlugin from 'wavesurfer.js/dist/plugin/wavesurfer.timeline.min';
import MinimapPlugin from 'wavesurfer.js/dist/plugin/wavesurfer.minimap.min';
class WaveSurferWrapper extends Component {
constructor(props) {
super(props);
props.init(this);
}
componentDidMount() {
this.wavesurfer = WaveSurfer.create({
container: '#waveform',
waveColor: 'violet',
plugins: [
TimelinePlugin.create({
container: '#wave-timeline',
}),
MinimapPlugin.create(),
],
});
this.load(this.props.url);
}
load(url) {
// this.wavesurfer.loadBlob(url);
this.wavesurfer.load('./test.ogg');
}
render() {
return (
<div id="waveform" className="wave-wrapper">
<div id="wave-timeline" className="wave-timeline" />
</div>
);
}
}
export default WaveSurferWrapper;