diff --git a/client/src/components/player.vue b/client/src/components/player.vue index 709e1bf..6749bc8 100644 --- a/client/src/components/player.vue +++ b/client/src/components/player.vue @@ -157,10 +157,11 @@ export default { }, created() { this.connectionPlayer(); + this.initializationInfo(); }, mounted() { - this.initializationInfo(); this.$store.dispatch('initPlayer'); + // console.log(this.$store.state); if (this.user?.id) { this.checkSongIsFavorite(); this.getSongList(); @@ -189,8 +190,13 @@ export default { }, methods: { async initializationInfo() { - return app.getNowplaying().then((responce) => responce.now_playing.song); + return app.getNowplaying().then((responce) => { + console.log(responce.now_playing.song); + this.$store.dispatch('setCurrentPlay', responce.now_playing.song); + console.log(this.$store.state); + }); }, + connectionPlayer() { if (this.connection) { this.connection.removePlay(); @@ -241,6 +247,7 @@ export default { }; delete params.unique_id; this.$store.dispatch('setCurrentPlay', params); + console.log(this.$store.state); } } } diff --git a/client/src/services/audio.js b/client/src/services/audio.js index ed180db..532793d 100644 --- a/client/src/services/audio.js +++ b/client/src/services/audio.js @@ -57,8 +57,8 @@ export default class extends REST { }; } - onHandler(event) { - this.connection.onmessage = event; + onHandler(callback) { + this.connection.onmessage = callback; } static getPlayList(station, params) { // return this._get(`station/${station}/playlists`, params, {}).then((data) => { diff --git a/client/src/settings/index.js b/client/src/settings/index.js index 705a3fc..39de1f0 100644 --- a/client/src/settings/index.js +++ b/client/src/settings/index.js @@ -41,5 +41,4 @@ const robotsTxt = { }, ], }; -console.log(urlPath); export { selfUrl, ajax, cache, urlPath, urlPathAudio, selfPath, robotsTxt }; diff --git a/client/src/store/index.js b/client/src/store/index.js index 52ed48e..630528b 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -62,6 +62,7 @@ export default createStore({ state.player = { ...state.player, ...params }; }, initPlayer(state) { + // console.log('mutation initPlayer', state); state.player.target = document.createElement('audio'); state.player.target.src = ''; state.player.target.preload = 'auto'; @@ -126,6 +127,7 @@ export default createStore({ context.commit('setPlayer', params); }, initPlayer(context) { + // console.log('action initPlayer'); context.commit('initPlayer'); }, handlerPlayer(context, params) {