добавлена обработка первого события в getPlaying
This commit is contained in:
parent
3da3f39f5a
commit
b82f4137a6
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue