added audioplayer contrib module
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
// Create a WaveSurfer instance
|
||||
var wavesurfer;
|
||||
|
||||
|
||||
// Init on DOM ready
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
wavesurfer = WaveSurfer.create({
|
||||
container: '#waveform',
|
||||
waveColor: '#428bca',
|
||||
progressColor: '#31708f',
|
||||
height: 120,
|
||||
barWidth: 3
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Bind controls
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var playPause = document.querySelector('#playPause');
|
||||
playPause.addEventListener('click', function () {
|
||||
wavesurfer.playPause();
|
||||
});
|
||||
|
||||
// Toggle play/pause text
|
||||
wavesurfer.on('play', function () {
|
||||
document.querySelector('#play').style.display = 'none';
|
||||
document.querySelector('#pause').style.display = '';
|
||||
});
|
||||
wavesurfer.on('pause', function () {
|
||||
document.querySelector('#play').style.display = '';
|
||||
document.querySelector('#pause').style.display = 'none';
|
||||
});
|
||||
|
||||
|
||||
// The playlist links
|
||||
var links = document.querySelectorAll('#playlist a');
|
||||
var currentTrack = 0;
|
||||
|
||||
// Load a track by index and highlight the corresponding link
|
||||
var setCurrentSong = function (index) {
|
||||
links[currentTrack].classList.remove('active');
|
||||
currentTrack = index;
|
||||
links[currentTrack].classList.add('active');
|
||||
wavesurfer.load(links[currentTrack].href);
|
||||
};
|
||||
|
||||
// Load the track on click
|
||||
Array.prototype.forEach.call(links, function (link, index) {
|
||||
link.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
setCurrentSong(index);
|
||||
});
|
||||
});
|
||||
|
||||
// Play on audio load
|
||||
wavesurfer.on('ready', function () {
|
||||
wavesurfer.play();
|
||||
});
|
||||
|
||||
// Go to the next track on finish
|
||||
wavesurfer.on('finish', function () {
|
||||
setCurrentSong((currentTrack + 1) % links.length);
|
||||
});
|
||||
|
||||
// Load the first track
|
||||
setCurrentSong(currentTrack);
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>wavesurfer.js | Playlist</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.min.js"></script>
|
||||
|
||||
<!-- App -->
|
||||
<script src="app.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<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">wavesurfer.js Playlist Demo</h1>
|
||||
</div>
|
||||
|
||||
<div id="demo">
|
||||
<div class="row" style="margin: 30px 0">
|
||||
<div class="col-sm-10">
|
||||
<div id="waveform">
|
||||
<!-- Here be waveform -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2">
|
||||
<button class="btn btn-success btn-block" id="playPause">
|
||||
<span id="play">
|
||||
<i class="glyphicon glyphicon-play"></i>
|
||||
Play
|
||||
</span>
|
||||
|
||||
<span id="pause" style="display: none">
|
||||
<i class="glyphicon glyphicon-pause"></i>
|
||||
Pause
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-group" id="playlist">
|
||||
<a href="../media/demo.wav" class="list-group-item">
|
||||
<i class="glyphicon glyphicon-play"></i>
|
||||
czskamaarù – Trou
|
||||
<span class="badge">0:21</span>
|
||||
</a>
|
||||
|
||||
<a href="../panner/media.wav" class="list-group-item">
|
||||
<i class="glyphicon glyphicon-play"></i>
|
||||
日本人の話し
|
||||
<span class="badge">1:04</span>
|
||||
</a>
|
||||
|
||||
<a href="../elan/transcripts/001z.mp3" class="list-group-item">
|
||||
<i class="glyphicon glyphicon-play"></i>
|
||||
Рассказы о сновидениях
|
||||
<span class="badge badge-info">1:26</span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer row">
|
||||
<div class="col-sm-12">
|
||||
</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 rel="license" href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause License</a>.
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5">
|
||||
<p>
|
||||
Audio sources:<br />
|
||||
<a rel="nofollow" href="http://www.jamendo.com/en/track/661578/trou"><b>Trou</b> <span class="muted">by</span> <b>czskamaarù</b></a>,
|
||||
<a rel="nofollow" href="http://spokencorpora.ru/">spokencorpora.ru</a>
|
||||
</p>
|
||||
</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>
|
||||
Reference in New Issue
Block a user