fix player

This commit is contained in:
Stepan Fedyanin 2024-06-13 07:32:32 +05:00
parent 97cfdb508a
commit f433380466
4 changed files with 114 additions and 88 deletions

View File

@ -73,6 +73,7 @@ export default boot(async ({ app, router }) => {
}),
toggle: createInput(toggle, {
props: ['placeholder', 'disabled', 'readonly'],
emits: ['toggle']
}),
},
};

View File

@ -1,27 +1,42 @@
<template>
<input
class="input field__checkbox-input"
:id="props.context.id"
:value="props.context._value"
:id="context.id"
:checked="context._value"
:disabled="disabled"
:readonly="readonly"
type="checkbox"
@change="change"
>
<label class="field__checkbox-label" :for="props.context.id">
{{ props.context.label }}
<label class="field__checkbox-label" :for="context.id">
{{ context.label }}
</label>
</template>
<script setup>
<script>
import {defineProps, ref, onUpdated, computed} from 'vue';
const props = defineProps({
export default {
props: {
context: {
type: Object,
default: () => {}
default: () => {
}
});
const placeholder = props.context.placeholder || '';
const disabled = props.context.disabled || false;
const readonly = props.context.readonly || false;
}
},
data() {
return {
placeholder: this.context.placeholder || '',
disabled: this.context.disabled || false,
readonly: this.context.readonly || false,
}
},
methods: {
change() {
this.context.node.input(!this.context._value);
}
}
}
</script>

View File

@ -16,11 +16,11 @@
<div class="player__favorites" :class="[isFavorites&&'m--active']" @click="handlerFavorites">
</div>
<div class="player__tools">
{{isLive}}
<FormKit
v-model="isLive"
type="toggle"
label="Включить мою музыку"
@change="changeLive"
/>
<div class="player__volume">
<span @click="setVolume"/>
@ -51,7 +51,7 @@ export default {
isFavorites: false,
isPlayRadio: true,
connection: null,
isLive: false
isLive: !this.$store.state.currentPlay.live,
}
},
computed: {
@ -67,20 +67,21 @@ export default {
},
watch: {
'currentPlay': {
immediate: true,
immediate: false,
handler() {
console.debug('this.currentPlay.live',!this.currentPlay.live)
this.isLive = !this.currentPlay.live
},
if (this.isLive!==!this.currentPlay.live){
this.isLive = !this.currentPlay.live;
}
},
},
},
created() {
this.connectionPlayer();
},
mounted() {
// if (!this.player.target){
if (!this.player.target) {
this.$store.dispatch('initPlayer');
// }
}
},
methods: {
connectionPlayer() {
@ -99,7 +100,7 @@ export default {
if (data.np.station.listen_url !== this.player.target.src) {
this.$store.dispatch('changePlayer', data.np.station.listen_url);
}
this.$store.dispatch('setCurrentPlay', {...data.np.now_playing.song, live: false});
this.$store.dispatch('setCurrentPlay', {...data.np.now_playing.song, live: true});
}
}
},
@ -131,7 +132,16 @@ export default {
changeVolume() {
this.$store.dispatch('handlerPlayer', {volume: 100});
},
changeLive(e) {
console.log(e)
if (this.currentPlay.live) {
this.$store.dispatch('setCurrentPlay', {live: false});
console.log('избранное')
} else {
this.$store.dispatch('setCurrentPlay', {live: true});
console.log('поток')
}
}
}
}
</script>

View File

@ -22,7 +22,7 @@ export default createStore({
player:{
target: null,
volume: 50,
live: false,
live: true,
}
}
},
@ -53,7 +53,7 @@ export default createStore({
state.player.target.src = '';
state.player.target.preload = 'auto';
state.player.target.controls = true;
console.log(state.player.target)
console.log('initPlayer',state.player.target)
},
changePlayer(state, params){
state.player.target.src = params;