fix global player volume from store

This commit is contained in:
Jonas Heinrich 2020-10-25 10:03:23 +01:00
parent 333a7d93b2
commit 8154e5d67b
2 changed files with 15 additions and 14 deletions

View File

@ -53,11 +53,9 @@ export default {
pageLoading: false, pageLoading: false,
blurHashes: require('../assets/blurHashes.json'), blurHashes: require('../assets/blurHashes.json'),
}), }),
provide: { computed: {
player: { player() {
isPlaying: false, return this.$store.state.player
isBuffering: false,
volume: 0,
}, },
}, },
watch: { watch: {
@ -109,23 +107,22 @@ export default {
* @param {Object} station Station object * @param {Object} station Station object
*/ */
doPlay(station) { doPlay(station) {
const vm = this
if (audioPlayer !== null) { if (audioPlayer !== null) {
audioPlayer.fade(1, 0, 500) // FIXME persistent volume state audioPlayer.fade(vm.player.volume, 0, 500)
// FIXME fade out
} }
this.$jquery.get('http://de1.api.radio-browser.info/json/url/' + station.stationuuid, this.$jquery.get('http://de1.api.radio-browser.info/json/url/' + station.stationuuid,
{ {
'User-Agent': 'Nextcloud Radio/1.0.0', // FIXME global version, doesnt seem to work 'User-Agent': 'Nextcloud Radio/1.0.0', // FIXME global version, doesnt seem to work
}) })
const vm = this
audioPlayer = new Howl({ audioPlayer = new Howl({
src: [station.url_resolved], src: [station.url_resolved],
volume: 0, volume: vm.player.volume,
onfade() { /* onfade() { // FIXME
if (this.volume() === 0) { if (this.volume() === 0) {
this.unload() this.unload()
} }
}, }, */
onplay() { onplay() {
vm.$store.dispatch('isPlaying', true) vm.$store.dispatch('isPlaying', true)
vm.$store.dispatch('isBuffering', false) vm.$store.dispatch('isBuffering', false)
@ -138,9 +135,13 @@ export default {
vm.$store.dispatch('isPlaying', true) vm.$store.dispatch('isPlaying', true)
vm.$store.dispatch('isBuffering', true) vm.$store.dispatch('isBuffering', true)
}, },
onstop() {
vm.$store.dispatch('isPlaying', false)
vm.$store.dispatch('isBuffering', false)
},
}) })
audioPlayer.play() audioPlayer.play()
audioPlayer.fade(0.1, 1, 500) // FIXME persistent volume state audioPlayer.fade(0, vm.player.volume, 500)
/* const stationMetadata = document.getElementById('stationMetadata') /* const stationMetadata = document.getElementById('stationMetadata')
stationMetadata.textContent = station.name */ stationMetadata.textContent = station.name */

View File

@ -9,16 +9,16 @@
</div> </div>
<div id="volumeicon" class="full" /> <div id="volumeicon" class="full" />
<input <input
v-model="sliderVal"
class="volume" class="volume"
type="range" type="range"
name="volume" name="volume"
min="0" min="0"
max="1" max="1"
step=".05" step=".05"
value="this.volume" :value="player.volume"
@input="changeVolume"> @input="changeVolume">
<span class="stationMetadata" /> <span class="stationMetadata" />
{{ player.volume }}
</div> </div>
</template> </template>