分類
<script src="js/jquery.min.js"></script> <script src="js/wavesurfer.min.js"></script>
<script> //音頻 1-4 數(shù)組排列 var music = ['0.mp3'] //音階 1-4 數(shù)組排列 var allArr = [ [0.6328, 0.6093, 0.3828, 0.4335, 0.3632, 0.414, 0.4804, 0.3085, 0.4492, 0.375, 0.625, 0.4648, 0.4335, 0.3867, 0.4101, 0.3945, 0.1992, 0.1757, 0.1601, 0.1132, 0.0859, 0.5976, 0.6132, 0.4257, 0.4257, 0.3398, 0.414, 0.3671, 0.3437, 0.4296, 0.3671, 0.6289, 0.4687, 0.4726, 0.3828, 0.5, 0.3007, 0.2304, 0.1562, 0.125, 0.4218, 0.3867, 0.6328, 0.6054, 0.5937, 0.2734, 0.2617, 0.2382, 0.5859, 0.3242, 0.2187, 0.1445, 0.6757, 0.3476, 0.621, 0.5351, 0.2812, 0.1523, 0.1445, 0.0937, 0.5625, 0.5976, 0.414, 0.3359, 0.2695, 0.1914, 0.5078, 0.3359, 0.2773, 0.2031, 0.1679, 0.1523, 0.6015, 0.6484, 0.621, 0.4296, 0.332, 0.2773, 0.7539, 0.4218, 0.3203, 0.1992, 0.1601, 0.1289, 0.5976, 0.3554, 0.2812, 0.1875, 0.1679, 0.1132, 0.1015, 0.0781, 0.625, 0.582, 0.4882, 0.414, 0.4296, 0.3828, 0.4453, 0.3867, 0.4023, 0.3945, 0.6367, 0.496, 0.4687, 0.4335, 0.2851, 0.3867, 0.1875, 0.1718, 0.1406, 0.121, 0.0781, 0.6328, 0.6171, 0.4453, 0.4453, 0.4726, 0.3242, 0.4257, 0.3398, 0.4609, 0.3593, 0.6289, 0.4765, 0.5, 0.4023, 0.4804, 0.332, 0.207, 0.1484, 0.1171, 0.0859, 0.4296, 0.6367, 0.5312, 0.5781, 0.3046, 0.2617, 0.2148, 0.6015, 0.3671, 0.2343, 0.1289, 0.1328, 0.6523, 0.5781, 0.4882, 0.2265, 0.1601, 0.1757, 0.082, 0.5742, 0.6289, 0.4804, 0.3359, 0.2968, 0.2109, 0.4882, 0.3398, 0.2656, 0.1796, 0.1718, 0.1601, 0.5976, 0.6406, 0.6328, 0.4921, 0.3359, 0.2617, 0.6953, 0.4218, 0.3359, 0.2265, 0.1953, 0.1601, 0.5937, 0.3828, 0.3632, 0.2109, 0.1679, 0.1289, 0.0937, 0.539, 0.4179, 0.332, 0.2421, 0.125, 0.082, 0.0625, 0.0468, 0.0507, 0.0312, 0.0273, 0.0156, 0.0156, 0.0039, 0.0039, 0, 0, 0, 0, 0, 0, 0, 0] ] //動態(tài)創(chuàng)建播放標簽 var html = '' for (var i = 0; i < music.length; i++) { html = '<div class="box">' + '<div class="group"><a href="javascript:" id="btnPlay' + i + '" role="btnPlay" tabindex="' + i + '">播放</a>' + '<a href="javascript:" id="btnPause' + i + '" role="btnPause" tabindex="' + i + '">暫停</a></div>' + '<div id="waveform' + i + '" class="waveform"></div>' + '</div>' $("body").append(html); } $(".waveform").each(function (i, item) { var wavesurfer = $(this).attr("id"); wavesurfer = WaveSurfer.create({ container: '#' + wavesurfer, barWidth: 2, height: 65, waveColor: '#428bca', progressColor: 'green', cursorColor: 'red', cursorWidth: 3 }); // wavesurfer.load() 一個參數(shù)的時候,進入頁面音樂都加載, // 2個參數(shù) 先加載軌道 點擊哪個音樂加載哪個 // 詳情可F12 更改參數(shù) 看network里的變化 wavesurfer.load(music[i], allArr[i]); // 可獲取音軌數(shù)據(jù)(上述音軌數(shù)組在此處獲取,正式項目應(yīng)該后臺獲取音軌數(shù)據(jù)) // setTimeout(function () { // console.log(wavesurfer.exportPCM()) // }, 1000) //點擊播放 $("#btnPlay" + i).click(function () { $("a[role=btnPause]").click(); wavesurfer.play(); $("#btnPlay" + i).hide() $("#btnPause" + i).show() }); // 點擊暫停 $("#btnPause" + i).click(function () { wavesurfer.pause(); $("#btnPlay" + i).show() $("#btnPause" + i).hide() }); }); </script>
以上是單個mp3音頻播放調(diào)用。
1. 本站所有素材(未指定商用),僅限學(xué)習(xí)交流。
2. 會員在本站下載的原創(chuàng)商用和VIP素材后,只擁有使用權(quán),著作權(quán)歸原作者及17素材網(wǎng)所有。
3. 原創(chuàng)商用和VIP素材,未經(jīng)合法授權(quán),請勿用于商業(yè)用途,會員不得以任何形式發(fā)布、傳播、復(fù)制、轉(zhuǎn)售該素材,否則一律封號處理。
4. 本平臺織夢模板僅展示和個人非盈利用途,織夢系統(tǒng)商業(yè)用途請預(yù)先授權(quán)。