From eeeb03b31357c753f4eb3e7f4e9113f5c5a13ef8 Mon Sep 17 00:00:00 2001 From: An Phan Date: Sun, 3 Jan 2016 16:09:34 +0800 Subject: [PATCH] Playback now initializes only once --- resources/assets/js/services/playback.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resources/assets/js/services/playback.js b/resources/assets/js/services/playback.js index 78757e3c..3f955936 100644 --- a/resources/assets/js/services/playback.js +++ b/resources/assets/js/services/playback.js @@ -14,6 +14,7 @@ export default { player: null, $volumeInput: null, repeatModes: ['NO_REPEAT', 'REPEAT_ALL', 'REPEAT_ONE'], + initialized: false, /** * Initialize the playback service for this whole Koel app. @@ -21,6 +22,11 @@ export default { * @param object app The root Vue component. */ init(app) { + // We don't need to init this service twice, or the media events will be duplicated. + if (this.initialized) { + return; + } + this.app = app; plyr.setup({ @@ -65,6 +71,8 @@ export default { // On init, set the volume to the value found in the local storage. this.setVolume(preferenceStore.get('volume')); + + this.initialized = true; }, /**