added audioplayer contrib module
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>wavesurfer.js | Equalizer Example</title>
|
||||
|
||||
<link href="data:image/gif;" rel="icon" type="image/x-icon" />
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<link rel="stylesheet" href="../css/style.css" />
|
||||
<link rel="stylesheet" href="../css/ribbon.css" />
|
||||
<link rel="screenshot" itemprop="screenshot" href="https://katspaugh.github.io/wavesurfer.js/example/screenshot.png" />
|
||||
|
||||
<!-- wavesurfer.js -->
|
||||
<script src="../../dist/wavesurfer.js"></script>
|
||||
|
||||
<!-- Demo -->
|
||||
<script src="main.js"></script>
|
||||
</head>
|
||||
|
||||
<body itemscope itemtype="http://schema.org/WebApplication">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<ul class="nav nav-pills pull-right">
|
||||
<li><a href="/"><i class="glyphicon glyphicon-home"></i></a></li>
|
||||
</ul>
|
||||
|
||||
<h1 itemprop="name">Equalizer Example</h1>
|
||||
</div>
|
||||
|
||||
<div id="demo">
|
||||
<div id="waveform">
|
||||
<div class="progress progress-striped active" id="progress-bar">
|
||||
<div class="progress-bar progress-bar-info"></div>
|
||||
</div>
|
||||
|
||||
<!-- Here be the waveform -->
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<button class="btn btn-primary" data-action="play">
|
||||
<i class="glyphicon glyphicon-play"></i>
|
||||
Play
|
||||
/
|
||||
<i class="glyphicon glyphicon-pause"></i>
|
||||
Pause
|
||||
</button>
|
||||
|
||||
<div id="equalizer">
|
||||
<!-- Here be equalizer sliders -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer row">
|
||||
<div class="col-sm-12">
|
||||
<a rel="license" href="https://opensource.org/licenses/BSD-3-Clause"><img alt="BSD-3-Clause License" style="border-width:0" src="https://img.shields.io/badge/License-BSD%203--Clause-blue.svg" /></a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-7">
|
||||
<span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type">wavesurfer.js</span> by <a href="https://github.com/katspaugh/wavesurfer.js">katspaugh</a> is licensed under a <a style="white-space: nowrap" rel="license" href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause License</a>.
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5">
|
||||
<div class="pull-right">
|
||||
<noindex>
|
||||
Demo music track is <a href="http://www.jamendo.com/en/track/661578/trou" rel="nofollow"><b>Trou</b> <span class="muted">by</span> <b>czskamaarù</b></a>. Thanks!
|
||||
</noindex>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="github-fork-ribbon-wrapper right">
|
||||
<div class="github-fork-ribbon">
|
||||
<a itemprop="isBasedOnUrl" href="https://github.com/katspaugh/wavesurfer.js">Fork me on GitHub</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-50026819-1', 'wavesurfer.fm');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,128 @@
|
||||
'use strict';
|
||||
|
||||
// Create an instance
|
||||
var wavesurfer;
|
||||
|
||||
// Init & load audio file
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Init
|
||||
wavesurfer = WaveSurfer.create({
|
||||
container: document.querySelector('#waveform'),
|
||||
waveColor: '#A8DBA8',
|
||||
progressColor: '#3B8686'
|
||||
});
|
||||
|
||||
// Load audio from URL
|
||||
wavesurfer.load('../media/demo.wav');
|
||||
|
||||
// Equalizer
|
||||
wavesurfer.on('ready', function () {
|
||||
var EQ = [
|
||||
{
|
||||
f: 32,
|
||||
type: 'lowshelf'
|
||||
}, {
|
||||
f: 64,
|
||||
type: 'peaking'
|
||||
}, {
|
||||
f: 125,
|
||||
type: 'peaking'
|
||||
}, {
|
||||
f: 250,
|
||||
type: 'peaking'
|
||||
}, {
|
||||
f: 500,
|
||||
type: 'peaking'
|
||||
}, {
|
||||
f: 1000,
|
||||
type: 'peaking'
|
||||
}, {
|
||||
f: 2000,
|
||||
type: 'peaking'
|
||||
}, {
|
||||
f: 4000,
|
||||
type: 'peaking'
|
||||
}, {
|
||||
f: 8000,
|
||||
type: 'peaking'
|
||||
}, {
|
||||
f: 16000,
|
||||
type: 'highshelf'
|
||||
}
|
||||
];
|
||||
|
||||
// Create filters
|
||||
var filters = EQ.map(function (band) {
|
||||
var filter = wavesurfer.backend.ac.createBiquadFilter();
|
||||
filter.type = band.type;
|
||||
filter.gain.value = 0;
|
||||
filter.Q.value = 1;
|
||||
filter.frequency.value = band.f;
|
||||
return filter;
|
||||
});
|
||||
|
||||
// Connect filters to wavesurfer
|
||||
wavesurfer.backend.setFilters(filters);
|
||||
|
||||
// Bind filters to vertical range sliders
|
||||
var container = document.querySelector('#equalizer');
|
||||
filters.forEach(function (filter) {
|
||||
var input = document.createElement('input');
|
||||
wavesurfer.util.extend(input, {
|
||||
type: 'range',
|
||||
min: -40,
|
||||
max: 40,
|
||||
value: 0,
|
||||
title: filter.frequency.value
|
||||
});
|
||||
input.style.display = 'inline-block';
|
||||
input.setAttribute('orient', 'vertical');
|
||||
wavesurfer.util.style(input, {
|
||||
'webkitAppearance': 'slider-vertical',
|
||||
width: '50px',
|
||||
height: '150px'
|
||||
});
|
||||
container.appendChild(input);
|
||||
|
||||
var onChange = function (e) {
|
||||
filter.gain.value = ~~e.target.value;
|
||||
};
|
||||
|
||||
input.addEventListener('input', onChange);
|
||||
input.addEventListener('change', onChange);
|
||||
});
|
||||
|
||||
// For debugging
|
||||
wavesurfer.filters = filters;
|
||||
});
|
||||
|
||||
// Log errors
|
||||
wavesurfer.on('error', function (msg) {
|
||||
console.log(msg);
|
||||
});
|
||||
|
||||
// Bind play/pause button
|
||||
document.querySelector(
|
||||
'[data-action="play"]'
|
||||
).addEventListener('click', wavesurfer.playPause.bind(wavesurfer));
|
||||
|
||||
// Progress bar
|
||||
(function () {
|
||||
var progressDiv = document.querySelector('#progress-bar');
|
||||
var progressBar = progressDiv.querySelector('.progress-bar');
|
||||
|
||||
var showProgress = function (percent) {
|
||||
progressDiv.style.display = 'block';
|
||||
progressBar.style.width = percent + '%';
|
||||
};
|
||||
|
||||
var hideProgress = function () {
|
||||
progressDiv.style.display = 'none';
|
||||
};
|
||||
|
||||
wavesurfer.on('loading', showProgress);
|
||||
wavesurfer.on('ready', hideProgress);
|
||||
wavesurfer.on('destroy', hideProgress);
|
||||
wavesurfer.on('error', hideProgress);
|
||||
}());
|
||||
});
|
||||
Reference in New Issue
Block a user