diff options
author | Florrie <towerofnix@gmail.com> | 2018-12-22 14:01:30 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-12-22 14:01:30 -0400 |
commit | 6fd767ec7aa32adab4143a4057f58a71d6205c6f (patch) | |
tree | 02c6245bcf0a2aaf39602ead53cbce60a419220e | |
parent | d3b452445076de6676391bf071f3c2d8f2048929 (diff) |
Make playFile return a promise
-rw-r--r-- | players.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/players.js b/players.js index be303fd..cc20667 100644 --- a/players.js +++ b/players.js @@ -80,6 +80,15 @@ module.exports.WebPlayer = class extends Player { playFile(file) { this.audioEl.src = file this.audioEl.play() + + return new Promise(resolve => { + const handleEnded = () => { + this.audioEl.removeEventListener('ended', handleEnded) + resolve() + } + + this.audioEl.addEventListener('ended', handleEnded) + }) } } |