我正試試使用 wavesurfer.js 顯示聲音的波形圖
目前程式碼如下:
<!doctype html>
<html style="background-color:#ECEBE8;">
<head>
<meta charset="utf-8" />
<title>wavesurfer</title>
<script src="https://unpkg.com/wavesurfer.js"></script>
<script type="text/javascript">
var wavesurfer = WaveSurfer.create({
container: '#waveform',
waveColor: 'violet',
progressColor: 'purple'
});
wavesurfer.load('voice/test.wav');
</script>
</head>
<body>
<div id="waveform" class="waveform"></div>
</body>
</html>
但無法呈現出波形圖
不知道是否哪裡使用錯誤?
還請指點...
謝謝
可以了!太感謝了!^^程式碼修改如下:
<!doctype html>
<html style="background-color:#ECEBE8;">
<head>
<meta charset="utf-8" />
<title>wavesurfer</title>
<script src="https://unpkg.com/wavesurfer.js"></script>
<script type="text/javascript">
function ShowVoice(){
var wavesurfer = WaveSurfer.create({
container: '#waveform',
waveColor: 'violet',
progressColor: 'purple'
});
wavesurfer.load('https://cors-anywhere.herokuapp.com/https://ccrma.stanford.edu/~jos/wav/cello82.wav')
wavesurfer.on('ready', function () {
wavesurfer.play();
});
}
</script>
</head>
<body onload="ShowVoice()">
<div id="waveform" class="waveform"></div>
</body>
</html>
拜見 H大神