Created
February 3, 2016 14:59
-
-
Save dariocravero/bbf3f1ac382965de3f9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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