This commit is contained in:
Norbaev 2024-06-28 09:03:52 +05:00
commit 15acc8c861
2 changed files with 31 additions and 23 deletions

View File

@ -156,7 +156,7 @@ export default {
},
},
created() {
this.initializationInfo();
// this.initializationInfo();
this.connectionPlayer();
},
mounted() {
@ -209,8 +209,10 @@ export default {
if (this.connection) {
this.connection.removePlay();
}
this.connection = new Player();
this.connection.init();
this.connection.onHandler(this.getPlaying);
},
checkSongIsFavorite() {
@ -235,16 +237,21 @@ export default {
});
},
getPlaying(e) {
// console.log('getPlaying', e);
const jsonData = JSON.parse(e.data);
console.log('jsonData', jsonData);
const data =
// Второй ответ
jsonData?.pub?.data ||
// Первый ответ
jsonData?.connect?.subs?.['station:it-radio']?.publications?.[0]?.data;
console.log('getPlaying', data);
if (jsonData?.pub?.data) {
const data = jsonData?.pub?.data;
if (!data) return;
if (this.currentPlay.live) {
const dataUrl = data.np.station.listen_url;
if (data.np.station.listen_url !== this.player.target.src) {
console.log(
'data.np.station.listen_url',
data.np.station.listen_url,
);
console.log('data.np.station.listen_url', data.np.station.listen_url);
this.$store.dispatch('changePlayer', data.np.station.listen_url);
console.log(this.player);
const params = {
@ -260,7 +267,6 @@ export default {
console.log(this.$store.state);
}
}
}
},
updateProgress(e) {
this.playerInfo = {

View File

@ -24,6 +24,8 @@ export default class extends REST {
this.connection = new EventSource(
sseBaseUri + '?' + sseUriParams.toString(),
);
// window.connection = this.connection;
this.connection.onopen = (e) => console.log('connected', e);
}
removePlay() {