получение данных о треке перед подключением стрима

This commit is contained in:
Norbaev 2024-06-27 10:30:37 +05:00
parent f5725e085b
commit 21481aca98
4 changed files with 13 additions and 5 deletions

View File

@ -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);
}
}
}

View File

@ -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) => {

View File

@ -41,5 +41,4 @@ const robotsTxt = {
},
],
};
console.log(urlPath);
export { selfUrl, ajax, cache, urlPath, urlPathAudio, selfPath, robotsTxt };

View File

@ -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) {