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

This commit is contained in:
Mike0001-droid 2024-06-28 16:20:57 +05:00
commit 9635fab52a
5 changed files with 93 additions and 72 deletions

View File

@ -83,5 +83,8 @@ module.exports = {
'vue/multi-word-component-names': 'off', 'vue/multi-word-component-names': 'off',
// allow debugger during development only // allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// Custom
// 'no-console': 'warn',
}, },
}; };

View File

@ -228,30 +228,30 @@ module.exports = configure(function (ctx) {
theme_color: '#027be3', theme_color: '#027be3',
icons: [ icons: [
{ {
src: 'icons/icon-128x128.png', src: 'icons/favicon-16x16.svg',
sizes: '128x128', sizes: '16x16',
type: 'image/png', type: 'svg',
},
{
src: 'icons/icon-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'icons/icon-256x256.png',
sizes: '256x256',
type: 'image/png',
},
{
src: 'icons/icon-384x384.png',
sizes: '384x384',
type: 'image/png',
},
{
src: 'icons/icon-512x512.png',
sizes: '512x512',
type: 'image/png',
}, },
// {
// src: 'icons/icon-192x192.png',
// sizes: '192x192',
// type: 'image/png',
// },
// {
// src: 'icons/icon-256x256.png',
// sizes: '256x256',
// type: 'image/png',
// },
// {
// src: 'icons/icon-384x384.png',
// sizes: '384x384',
// type: 'image/png',
// },
// {
// src: 'icons/icon-512x512.png',
// sizes: '512x512',
// type: 'image/png',
// },
], ],
}, },
}, },

View File

@ -156,12 +156,11 @@ export default {
}, },
}, },
created() { created() {
this.initializationInfo(); // this.initializationInfo();
this.connectionPlayer(); this.connectionPlayer();
}, },
mounted() { mounted() {
this.$store.dispatch('initPlayer'); this.$store.dispatch('initPlayer');
// console.log(this.$store.state);
if (this.user?.id) { if (this.user?.id) {
this.checkSongIsFavorite(); this.checkSongIsFavorite();
this.getSongList(); this.getSongList();
@ -193,14 +192,15 @@ export default {
app app
.getNowplaying() .getNowplaying()
.then((responce) => { .then((responce) => {
console.log(responce.now_playing.song); const { art, title, artist } = responce.now_playing.song;
console.log(art, title, artist);
this.$store.dispatch('setCurrentPlay', { this.$store.dispatch('setCurrentPlay', {
...this.currentPlay, ...this.currentPlay,
isLoader: false, isLoader: false,
...responce.now_playing.song, art,
title,
artist,
}); });
console.log(this.player.target.src);
// console.log(this.$store.state);
}) })
.catch((error) => console.log(error)); .catch((error) => console.log(error));
}, },
@ -209,9 +209,11 @@ export default {
if (this.connection) { if (this.connection) {
this.connection.removePlay(); this.connection.removePlay();
} }
this.connection = new Player(); this.connection = new Player();
this.connection.init(); this.connection.init();
this.connection.onHandler(this.getPlaying);
this.connection.onHandler(this.handlePlayer);
}, },
checkSongIsFavorite() { checkSongIsFavorite() {
app app
@ -234,17 +236,24 @@ export default {
console.error(err); console.error(err);
}); });
}, },
getPlaying(e) { handlePlayer(e) {
// console.log('getPlaying', e);
const jsonData = JSON.parse(e.data); const jsonData = JSON.parse(e.data);
if (jsonData?.pub?.data) { // console.log('jsonData', jsonData);
const data = jsonData?.pub?.data; const data =
// Второй ответ
jsonData?.pub?.data ||
// Первый ответ
jsonData?.connect?.subs?.['station:it-radio']?.publications?.[0]?.data;
// console.log('getPlaying', data);
if (!data) return;
if (this.currentPlay.live) { if (this.currentPlay.live) {
if (data.np.station.listen_url !== this.player.target.src) { const dataUrl = data.np.station.listen_url;
console.log( const playerUrl = this.player.target.src;
'data.np.station.listen_url', if (dataUrl !== playerUrl) {
data.np.station.listen_url, // console.log('data.np.station.listen_url', dataUrl);
); this.$store.dispatch('changePlayer', dataUrl);
this.$store.dispatch('changePlayer', data.np.station.listen_url);
console.log(this.player); console.log(this.player);
const params = { const params = {
...this.currentPlay, ...this.currentPlay,
@ -254,10 +263,9 @@ export default {
live: true, live: true,
currentIndex: null, currentIndex: null,
}; };
console.log('params in getPlaying ', params);
delete params.unique_id; delete params.unique_id;
this.$store.dispatch('setCurrentPlay', params); this.$store.dispatch('setCurrentPlay', params);
console.log(this.$store.state);
}
} }
} }
}, },
@ -358,6 +366,7 @@ export default {
app app
.getAudio(id) .getAudio(id)
.then((res) => { .then((res) => {
console.log('res в методе getAudio', res);
const blob = new Blob([res], { type: 'application/audio' }); const blob = new Blob([res], { type: 'application/audio' });
const audioUrl = URL.createObjectURL(blob); const audioUrl = URL.createObjectURL(blob);
this.$store.dispatch('changePlayer', audioUrl); this.$store.dispatch('changePlayer', audioUrl);

View File

@ -1,20 +1,28 @@
<!DOCTYPE html> <!doctype html>
<html lang="ru"> <html lang="ru">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no"> <meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=yes, initial-scale=1, maximum-scale=5, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>"> <meta
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> name="viewport"
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> content="user-scalable=yes, initial-scale=1, maximum-scale=5, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>"
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> />
<link rel="manifest" href="/site.webmanifest"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"> <link rel="icon" type="image/ico" href="favicon.ico" />
<meta name="msapplication-TileColor" content="#00a300"> <link
<meta name="theme-color" content="#119b58"> rel="icon"
</head> type="image/svg"
<body> sizes="16x16"
<!-- DO NOT touch the following DIV --> href="icons/favicon-16x16.svg"
<div id="q-app"></div> />
</body> <link rel="manifest" href="/site.webmanifest" />
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
<meta name="msapplication-TileColor" content="#00a300" />
<meta name="theme-color" content="#119b58" />
</head>
<body>
<!-- DO NOT touch the following DIV -->
<div id="q-app"></div>
</body>
</html> </html>

View File

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