Merge branch 'master' of git.flexites.org:Students/ITRadio

This commit is contained in:
Mike0001-droid 2024-06-26 16:33:20 +05:00
commit 232de56299
6 changed files with 31 additions and 6 deletions

View File

@ -8,7 +8,7 @@ ROBOTS_ALLOW=
ROBOTS_DISALLOW=["/"]
SERVICE_SELF_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_PORT=8000
SERVICE_API=/api

View File

@ -159,7 +159,7 @@ export default {
this.connectionPlayer();
},
mounted() {
console.log(this.currentPlay);
this.initializationInfo();
this.$store.dispatch('initPlayer');
if (this.user?.id) {
this.checkSongIsFavorite();
@ -188,6 +188,9 @@ export default {
}
},
methods: {
async initializationInfo() {
return app.getNowplaying().then((responce) => responce.now_playing.song);
},
connectionPlayer() {
if (this.connection) {
this.connection.removePlay();

View File

@ -1,6 +1,8 @@
import { urlPath as settings } from '@/settings';
import { REST, RESTError } from './rest';
// запросы на сервер Django
export default class extends REST {
static get settings() {
return settings;
@ -213,4 +215,19 @@ export default class extends REST {
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());

View File

@ -1,13 +1,18 @@
import { urlPathAudio as settings, urlPathAudio } from '@/settings';
import { urlPathAudio as settings } from '@/settings';
import { REST, RESTError } from './rest';
// запросы на AzuraCast
export default class extends REST {
connection = {};
static get settings() {
return settings;
}
init() {
const sseBaseUri = `${settings}/api/live/nowplaying/sse`;
// console.log('sseBaseUri', sseBaseUri);
const sseUriParams = new URLSearchParams({
cf_connect: JSON.stringify({
subs: {
@ -15,6 +20,7 @@ export default class extends REST {
},
}),
});
// console.log('sseUriParams', sseUriParams.toString());
this.connection = new EventSource(
sseBaseUri + '?' + sseUriParams.toString(),
);
@ -58,6 +64,7 @@ export default class extends REST {
// return this._get(`station/${station}/playlists`, params, {}).then((data) => {
return this._get(`radio.mp3`, params, {})
.then((data) => {
console.log(data);
return data;
})
.catch((error) => {

View File

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

View File

@ -67,7 +67,6 @@ export default createStore({
state.player.target.preload = 'auto';
state.player.target.controls = true;
state.player.target.volume = 0.5;
console.log('initPlayer', state.player.target);
},
changePlayer(state, params) {
const awaitPlay = () => {
@ -84,7 +83,6 @@ export default createStore({
state.player.target.src = params;
state.player.src = params;
console.log(state.player.target.src);
// state.currentPlay.isLoader = true;
state.player.target.addEventListener('canplaythrough', awaitPlay);
},