Skip to content

Instantly share code, notes, and snippets.

@dariocravero
Created February 3, 2016 14:59
Show Gist options
  • Save dariocravero/bbf3f1ac382965de3f9f to your computer and use it in GitHub Desktop.
Save dariocravero/bbf3f1ac382965de3f9f to your computer and use it in GitHub Desktop.
import { Howl } from 'howler/src/howler.core';
export default function createHowl(src, onEnd) {
return new Promise(function(resolve, reject) {
const howl = new Howl({
autoplay: false,
onend: onEnd,
src: [src],
onload() { resolve(howl) },
onloadeerror: reject
});
});
}
import createNode from './create-howl-node';
const nodes = {};
export function load({id, src, onEnd}) {
return createNode(src, onEnd)
.then(node => nodes[id] = node)
.then(node => ({
duration: node.duration()
}));
}
export function pause(id) {
nodes[id].pause();
}
export function play(id) {
nodes[id].play();
}
export function stop(id) {
nodes[id].stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment