добавил метод getNowplaying внутрь класса для запросов на приложение
This commit is contained in:
parent
43cae25e18
commit
178584220a
|
|
@ -8,7 +8,7 @@ ROBOTS_ALLOW=
|
||||||
ROBOTS_DISALLOW=["/"]
|
ROBOTS_DISALLOW=["/"]
|
||||||
SERVICE_SELF_URL=//it-radio.flexidev.ru
|
SERVICE_SELF_URL=//it-radio.flexidev.ru
|
||||||
SERVICE_URL=//it-radio.flexidev.ru
|
SERVICE_URL=//it-radio.flexidev.ru
|
||||||
SERVICE_URL_AUDIO=//azuracast.itradio.team
|
SERVICE_URL_AUDIO=//82.97.242.49:10084
|
||||||
SERVICE_PROTOCOL=http
|
SERVICE_PROTOCOL=http
|
||||||
SERVICE_PORT=8000
|
SERVICE_PORT=8000
|
||||||
SERVICE_API=/api
|
SERVICE_API=/api
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ export default {
|
||||||
this.connectionPlayer();
|
this.connectionPlayer();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log(this.currentPlay);
|
this.initializationInfo();
|
||||||
this.$store.dispatch('initPlayer');
|
this.$store.dispatch('initPlayer');
|
||||||
if (this.user?.id) {
|
if (this.user?.id) {
|
||||||
this.checkSongIsFavorite();
|
this.checkSongIsFavorite();
|
||||||
|
|
@ -188,6 +188,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async initializationInfo() {
|
||||||
|
return app.getNowplaying().then((responce) => responce.now_playing.song);
|
||||||
|
},
|
||||||
connectionPlayer() {
|
connectionPlayer() {
|
||||||
if (this.connection) {
|
if (this.connection) {
|
||||||
this.connection.removePlay();
|
this.connection.removePlay();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import { urlPath as settings } from '@/settings';
|
import { urlPath as settings } from '@/settings';
|
||||||
import { REST, RESTError } from './rest';
|
import { REST, RESTError } from './rest';
|
||||||
|
|
||||||
|
// запросы на сервер Django
|
||||||
|
|
||||||
export default class extends REST {
|
export default class extends REST {
|
||||||
static get settings() {
|
static get settings() {
|
||||||
return settings;
|
return settings;
|
||||||
|
|
@ -213,4 +215,19 @@ export default class extends REST {
|
||||||
throw new RESTError(error, 'Ошибка при получении плейлистов');
|
throw new RESTError(error, 'Ошибка при получении плейлистов');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getNowplaying(station, params) {
|
||||||
|
return this._get('/radio/song/get_nowplaying/', params, {})
|
||||||
|
.then((data) => {
|
||||||
|
return data;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
throw new RESTError(
|
||||||
|
error,
|
||||||
|
'Ошибка при получении информации о текущем треке',
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(Django.getNowplaying());
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,18 @@
|
||||||
import { urlPathAudio as settings, urlPathAudio } from '@/settings';
|
import { urlPathAudio as settings } from '@/settings';
|
||||||
import { REST, RESTError } from './rest';
|
import { REST, RESTError } from './rest';
|
||||||
|
|
||||||
|
// запросы на AzuraCast
|
||||||
|
|
||||||
export default class extends REST {
|
export default class extends REST {
|
||||||
|
connection = {};
|
||||||
|
|
||||||
static get settings() {
|
static get settings() {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
const sseBaseUri = `${settings}/api/live/nowplaying/sse`;
|
const sseBaseUri = `${settings}/api/live/nowplaying/sse`;
|
||||||
|
// console.log('sseBaseUri', sseBaseUri);
|
||||||
const sseUriParams = new URLSearchParams({
|
const sseUriParams = new URLSearchParams({
|
||||||
cf_connect: JSON.stringify({
|
cf_connect: JSON.stringify({
|
||||||
subs: {
|
subs: {
|
||||||
|
|
@ -15,6 +20,7 @@ export default class extends REST {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
// console.log('sseUriParams', sseUriParams.toString());
|
||||||
this.connection = new EventSource(
|
this.connection = new EventSource(
|
||||||
sseBaseUri + '?' + sseUriParams.toString(),
|
sseBaseUri + '?' + sseUriParams.toString(),
|
||||||
);
|
);
|
||||||
|
|
@ -58,6 +64,7 @@ export default class extends REST {
|
||||||
// return this._get(`station/${station}/playlists`, params, {}).then((data) => {
|
// return this._get(`station/${station}/playlists`, params, {}).then((data) => {
|
||||||
return this._get(`radio.mp3`, params, {})
|
return this._get(`radio.mp3`, params, {})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
console.log(data);
|
||||||
return data;
|
return data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,5 @@ const robotsTxt = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
console.log(urlPath);
|
||||||
export { selfUrl, ajax, cache, urlPath, urlPathAudio, selfPath, robotsTxt };
|
export { selfUrl, ajax, cache, urlPath, urlPathAudio, selfPath, robotsTxt };
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ export default createStore({
|
||||||
state.player.target.preload = 'auto';
|
state.player.target.preload = 'auto';
|
||||||
state.player.target.controls = true;
|
state.player.target.controls = true;
|
||||||
state.player.target.volume = 0.5;
|
state.player.target.volume = 0.5;
|
||||||
console.log('initPlayer', state.player.target);
|
|
||||||
},
|
},
|
||||||
changePlayer(state, params) {
|
changePlayer(state, params) {
|
||||||
const awaitPlay = () => {
|
const awaitPlay = () => {
|
||||||
|
|
@ -84,7 +83,6 @@ export default createStore({
|
||||||
|
|
||||||
state.player.target.src = params;
|
state.player.target.src = params;
|
||||||
state.player.src = params;
|
state.player.src = params;
|
||||||
console.log(state.player.target.src);
|
|
||||||
// state.currentPlay.isLoader = true;
|
// state.currentPlay.isLoader = true;
|
||||||
state.player.target.addEventListener('canplaythrough', awaitPlay);
|
state.player.target.addEventListener('canplaythrough', awaitPlay);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue