A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
10
playing: false,11
loading: false,12
error: false,13
title: '- No song title available -',13
title: null,14
interval: null,15
resume: false,16
state
26
this.error = false;27
if(station !== null) {28
this.loading = true;29
this.title = '- No song title available -';29
this.title = null;30
this.updateMediaSession();31
state.open = true;32
}
34
},35
methods: {36
$lang,37
async setLike(is_favorite) {38
try {39
await http`${is_favorite ? 'post' : 'delete'}::/api/favorite`(this.station.id);40
this.station.is_favorite = is_favorite;41
state.app.$refs.favorites.doFetch();42
}43
catch(error) {44
console.log(error);45
}46
},37
setPlaying(playing) {38
if(this.error || this.loading) {39
return;
74
updateMediaSession() {75
if('mediaSession' in navigator) {76
navigator.mediaSession.metadata = new MediaMetadata({87
title: this.title,77
title: this.title ?? $lang('player.no-song-title'),78
artist: this.station.name,79
artwork: [80
{ src: this.station.icon, sizes: '96x96', type: 'image/jpg' },
90
async fetchSong() {91
try {92
const song = await http`get::/api/song`(this.station);103
this.title = song === '' ? '- No song title available -' : song;93
this.title = song === '' ? null : song;94
}95
catch(err) {96
console.error(err);107
this.title = '- No song title available -';97
clearInterval(this.interval);98
this.title = null;99
}100
this.updateMediaSession();101
},
186
{{station.name}}187
</p>188
<p class="text-md text-gray-400 overflow-hidden text-ellipsis whitespace-nowrap select-none pointer-events-none text-center sm:text-left">198
{{title ?? $lang('player.loading')}}189
{{title ?? $lang('player.no-song-title')}}190
</p>191
</div>192
<div class="inline-flex gap-4 z-10 pr-2">
185
`186
});187
})();