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, { toggle: createInput(toggle, {
props: ['placeholder', 'disabled', 'readonly'], props: ['placeholder', 'disabled', 'readonly'],
emits: ['toggle']
}), }),
}, },
}; };

View File

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

View File

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

View File

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