Wavesurfer timeline插件下载已被弃用?

时间:2017-11-01 06:34:53

标签: javascript jquery plugins wavesurfer.js

我想使用wavesurfer.js为数字音频文件添加时间轴,遗憾的是我的代码在这里不起作用。我可以知道从哪里可以为我的文件加载timeline.js? waveurfer时间轴插件是否已被弃用?

<html>
    <head>
    <title>webapp</title>


    <!-- main wavesurfer.js lib -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/wavesurfer.js/1.2.3/wavesurfer.min.js"></script>

    <!-- wavesurfer.js timeline -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/wavesurfer.js/1.2.3/plugin/wavesurfer.timeline.min.js"></script>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/sidebar.css" type="text/css"/>

    </head>
    <body>
<div id="waveform-timeline"></div>    
            <div id="audio-spectrum"></div>
 </body>
    </html>

的javascript:

var Spectrum = WaveSurfer.create({
                    container: '#audio-spectrum',
                    progressColor: "#03a9f4",
                    container: document.querySelector('#audio-spectrum'),
                    backend: 'MediaElement'
                });

Spectrum.on('ready', function () {
                   var timeline = Object.create(Spectrum.Timeline);

                       timeline.init({
                       Spectrum: Spectrum,
                       container: "#wave-timeline"
                       });
                     });

                // Load the audio file from your domain !
                Spectrum.load('http://ia902606.us.archive.org/35/items/shortpoetry_047_librivox/song_cjrg_teasdale_64kb.mp3');

错误表示waveurfer未定义。

1 个答案:

答案 0 :(得分:0)

时间轴插件要求您将waveurfer实例传递给其create函数。您正在密钥Spectrum下传递 - 这就是为什么无法找到它。将时间轴初始化代码更改为:

// ...
timeline.init({
  wavesurfer: Spectrum,
  container: "#wave-timeline"
});
// ...