catch more errors, fix errors

This commit is contained in:
Jonas Heinrich 2020-11-17 14:33:27 +01:00
parent 2d68c45970
commit ac8c6e31be
2 changed files with 51 additions and 40 deletions

View File

@ -71,7 +71,7 @@ export default {
tableData: [], tableData: [],
pageLoading: false, pageLoading: false,
blurHashes: require('../assets/blurHashes.json'), blurHashes: require('../assets/blurHashes.json'),
favorites: null, favorites: [],
showSidebar: false, showSidebar: false,
sidebarStation: [], sidebarStation: [],
}), }),
@ -164,8 +164,10 @@ export default {
* @param {Object} station Station object * @param {Object} station Station object
*/ */
async doPlay(station) { async doPlay(station) {
const vm = this const vm = this
vm.$store.dispatch('isBuffering', true)
if (audioPlayer !== null) { if (audioPlayer !== null) {
audioPlayer.fade(vm.player.volume, 0, 500) audioPlayer.fade(vm.player.volume, 0, 500)
} }
@ -180,6 +182,7 @@ export default {
Howler.unload() Howler.unload()
audioPlayer = new Howl({ audioPlayer = new Howl({
src: stationSrc, src: stationSrc,
html5: true,
volume: vm.player.volume, volume: vm.player.volume,
/* onfade() { // FIXME /* onfade() { // FIXME
if (this.volume() === 0) { if (this.volume() === 0) {
@ -187,6 +190,7 @@ export default {
} }
}, */ }, */
onplay() { onplay() {
console.log('onplay')
vm.$store.dispatch('isPlaying', true) vm.$store.dispatch('isPlaying', true)
vm.$store.dispatch('isBuffering', false) vm.$store.dispatch('isBuffering', false)
}, },
@ -194,12 +198,13 @@ export default {
vm.$store.dispatch('isPlaying', false) vm.$store.dispatch('isPlaying', false)
vm.$store.dispatch('isBuffering', false) vm.$store.dispatch('isBuffering', false)
}, },
onload() { onend() {
vm.$store.dispatch('isPlaying', true) showError(t('radio', 'Lost connection to radio station, retrying ...'))
vm.$store.dispatch('isPlaying', false)
vm.$store.dispatch('isBuffering', true) vm.$store.dispatch('isBuffering', true)
}, },
onstop() { onloaderror() {
vm.$store.dispatch('isPlaying', false) showError(t('radio', 'Unable to reach and play radio station'))
vm.$store.dispatch('isBuffering', false) vm.$store.dispatch('isBuffering', false)
}, },
}) })
@ -207,7 +212,11 @@ export default {
audioPlayer.fade(0, vm.player.volume, 500) audioPlayer.fade(0, vm.player.volume, 500)
/* Count click */ /* Count click */
try {
axios.get(this.$apiUrl + '/json/url/' + station.stationuuid) axios.get(this.$apiUrl + '/json/url/' + station.stationuuid)
} catch (error) {
showError(t('radio', 'Unable to count play on remote API'))
}
/* Put into recent stations */ /* Put into recent stations */
try { try {
@ -232,10 +241,6 @@ export default {
}, },
/**
* Fetching radio stations using Radio-Browser.info API
* @param {String} menuState Entries to load
*/
async loadStations(menuState = 'TOP') { async loadStations(menuState = 'TOP') {
const vm = this const vm = this
@ -290,6 +295,7 @@ export default {
queryURI = generateUrl('/apps/radio/api/recent') queryURI = generateUrl('/apps/radio/api/recent')
} }
try {
await axios.get(queryURI, { await axios.get(queryURI, {
params: { params: {
limit: 20, limit: 20,
@ -310,6 +316,9 @@ export default {
vm.tableData = vm.tableData.concat(response.data) vm.tableData = vm.tableData.concat(response.data)
vm.pageLoading = false vm.pageLoading = false
}) })
} catch (error) {
showError(t('radio', 'Could not fetch stations from remote API'))
}
}, },
/** /**
@ -335,6 +344,7 @@ export default {
async loadFavorites() { async loadFavorites() {
const vm = this const vm = this
try {
await axios.get(generateUrl('/apps/radio/api/favorites')) await axios.get(generateUrl('/apps/radio/api/favorites'))
.then(function(response) { .then(function(response) {
const favorites = [] const favorites = []
@ -343,6 +353,9 @@ export default {
} }
vm.favorites = favorites vm.favorites = favorites
}) })
} catch (error) {
showError(t('radio', 'Unable to load favorites'))
}
}, },
toggleSidebar(station = null) { toggleSidebar(station = null) {

View File

@ -24,8 +24,6 @@
@change="saveVolume($event)"> @change="saveVolume($event)">
<div class="playerMetadata"> <div class="playerMetadata">
{{ player.title }} {{ player.title }}
{{ player.isPlaying }}
{{ player.isBuffering }}
</div> </div>
</div> </div>
</template> </template>