diff options
Diffstat (limited to 'frontend/site/audio/audio.player.js')
| -rw-r--r-- | frontend/site/audio/audio.player.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/frontend/site/audio/audio.player.js b/frontend/site/audio/audio.player.js index 4f33d9d..e6e8f44 100644 --- a/frontend/site/audio/audio.player.js +++ b/frontend/site/audio/audio.player.js @@ -25,6 +25,13 @@ export default class AudioPlayer { ) } + stop(id) { + if (this.players[id]) { + this.players[id].type = "done" + this.players[id].stop() + } + } + done(id) { // console.log('remove', id) delete this.players[id] @@ -34,10 +41,7 @@ export default class AudioPlayer { const { background_audio_id, restart_audio, stop_all_sounds } = page.settings // console.log('playPage', page) if (stop_all_sounds) { - Object.keys(this.players).forEach(id => { - this.players[id].type = "done" - this.players[id].stop(true) - }) + Object.keys(this.players).forEach(id => this.stop(id)) } else if ( this.current_background_id && this.current_background_id !== background_audio_id @@ -88,6 +92,17 @@ export default class AudioPlayer { return this.players[id] } } + + playURL({ id, url }) { + this.players[id] = new Player({ + item: { id, url }, + tile: { settings: {} }, + type: "url", + done: this.done + }) + this.players[id].play() + return this.players[id] + } } class Player { |
