我正在尝试为我的应用程序中的音频和视频内容生成波形,目前使用 angular 6 和 TypeScript。我可以使用 wavesurfer.js 制作波形,但我无法让时间线插件正常工作。在我的 angular.json 我有这样的脚本
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/popper.js/dist/umd/popper.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js",
"node_modules/moment/min/moment.min.js",
"node_modules/wavesurfer.js/dist/wavesurfer.js",
"node_modules/wavesurfer.js/dist/plugin/wavesurfer.timeline.js"
]
在我的 component.ts 文件中,我有类似的代码
declare var WaveSurfer;
declare var TimelinePlugin;
export class TranscriptComponent implements OnInit {
ngAfterViewInit() {
this.wavesurfer = WaveSurfer.create({
container: '#waveform',
waveColor: 'violet',
progressColor: 'purple',
cursorColor: '#d9fb36',
normalize: true,
skipLength: 15,
hideScrollbar: true,
backend: 'MediaElement',
plugins: [
TimelinePlugin.create({
// plugin options ...
})
]
});
}
如果没有插件,我可以获得波形,但如果我尝试添加插件,我会收到错误“TimelinePlugin 未定义”。谁能告诉我如何使用打字稿使用这些插件。一个例子会很棒。