|
@@ -1,22 +1,26 @@ |
|
|
import * as WaveformPlaylist from 'waveform-playlist'; |
|
|
import * as WaveformPlaylist from 'waveform-playlist'; |
|
|
import delay from 'delay'; |
|
|
import delay from 'delay'; |
|
|
|
|
|
import html from 'nanohtml' |
|
|
|
|
|
|
|
|
import { parseMediaFragmentIdentifier } from '../util/media-fragment-identifier.js'; |
|
|
import { parseMediaFragmentIdentifier } from '../util/media-fragment-identifier.js'; |
|
|
|
|
|
|
|
|
async function init() { |
|
|
async function init() { |
|
|
document.body.innerHTML = ` |
|
|
|
|
|
|
|
|
document.body.innerHTML = ''; |
|
|
|
|
|
|
|
|
|
|
|
const mainEl = html` |
|
|
<main> |
|
|
<main> |
|
|
<div id="controls"> |
|
|
<div id="controls"> |
|
|
<button id="playpause">⏯</button> |
|
|
|
|
|
|
|
|
<button id="playpause" onclick=${playpause}>⏯</button> |
|
|
<div> |
|
|
<div> |
|
|
<label for="volume" id="volume-label">🔊</label> |
|
|
<label for="volume" id="volume-label">🔊</label> |
|
|
<input type="range" min="0" max="100" value="100" id="volume" /> |
|
|
|
|
|
|
|
|
<input type="range" min="0" max="100" value="100" id="volume" oninput=${updateVolume}/> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div id="container"> |
|
|
<div id="container"> |
|
|
</div> |
|
|
</div> |
|
|
</main> |
|
|
</main> |
|
|
`; |
|
|
`; |
|
|
|
|
|
document.body.appendChild(mainEl); |
|
|
|
|
|
|
|
|
const playlist = WaveformPlaylist.init({ |
|
|
const playlist = WaveformPlaylist.init({ |
|
|
container: document.getElementById('container'), |
|
|
container: document.getElementById('container'), |
|
@@ -27,15 +31,13 @@ async function init() { |
|
|
|
|
|
|
|
|
const eventEmitter = playlist.getEventEmitter(); |
|
|
const eventEmitter = playlist.getEventEmitter(); |
|
|
|
|
|
|
|
|
// Hook up play/pause and volume inputs |
|
|
|
|
|
const playpauseEl = document.getElementById('playpause'); |
|
|
|
|
|
const volumeEl = document.getElementById('volume'); |
|
|
|
|
|
playpauseEl.addEventListener('click', |
|
|
|
|
|
e => eventEmitter.emit(playlist.isPlaying() ? 'pause' : 'play') |
|
|
|
|
|
); |
|
|
|
|
|
volumeEl.addEventListener('input', |
|
|
|
|
|
e => eventEmitter.emit("mastervolumechange", e.target.value) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
function playpause() { |
|
|
|
|
|
eventEmitter.emit(playlist.isPlaying() ? 'pause' : 'play'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function updateVolume(event) { |
|
|
|
|
|
eventEmitter.emit('mastervolumechange', event.target.value); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Load the file |
|
|
// Load the file |
|
|
await playlist.load([{ |
|
|
await playlist.load([{ |
|
|