A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
3
import VButton from '../element/button.js';4
import VIcon from '../element/icon.js';5
import VImage from '../element/image.js';6
import VPlayButton from '../element/play-button.js';7
import VStation from '../component/station.js';9
export default {
18
VButton,19
VIcon,20
VImage,20
VStation21
VStation,22
VPlayButton23
},24
methods: {25
$lang,26
duration,25
async load(stationId) {26
this.station = await http`get::/api/station/${stationId}`();27
async show(station) {28
this.station = await http`get::/api/station/${station.id}`();29
this.group = null;30
if(this.station.group_id) {31
this.group = await http`get::/api/group/${this.station.group_id}`();
43
console.log(error);44
}45
},44
setStation(station) {45
state.station = station;46
state.app.$refs.player.open = true;47
},46
onTouchStart(event) {47
this.touch = event.changedTouches[0];48
this.target = event.target;
180
<span v-for="tag in station.tags" class="cursor-pointer text-md text-white/90 font-medium items-center gap-[5px] bg-zinc-900 hover:bg-zinc-800 rounded-[4px] text-[14px] px-[14px] inline-flex h-[34px] leading-[34px]">{{tag}}</span>181
</div>182
<div class="flex gap-3">185
<v-button186
icon="player-play"187
@click="() => setStation(station)"188
:text="$lang('global.listen')"189
class="bg-zinc-900 hover:bg-white px-1"190
></v-button>183
<v-play-button :station="station"></v-play-button>184
<v-button185
:icon="station.is_favorite ? 'bookmark-off' : 'bookmark'"186
:title="$lang(station.is_favorite ? 'global.unlike' : 'global.like')"
16
resume: false,17
open: false,18
tooLong: false,19
animationDuration: null19
animationDuration: null,20
state21
};22
},23
components: {
26
VImage27
},28
watch: {28
station(value, old) {29
if(value?.id === old?.id) {30
return;31
}32
this.playing = false;33
this.error = false;34
if(value !== null) {35
this.loading = true;36
this.title = null;37
this.updateMediaSession();38
}39
},29
async title(value) {30
await this.$nextTick();31
const outer = this.$refs.songtitle;
36
},37
methods: {38
$lang,50
async openDetail(station) {51
await state.app.$refs.detail.load(station.id);52
this.open = false;39
play(station) {40
if(this.station?.id === station?.id) {41
return;42
}43
this.station = station;44
this.playing = false;45
this.error = false;46
if(this.station !== null) {47
this.loading = true;48
this.title = null;49
this.updateMediaSession();50
}51
},52
setPlaying(playing) {53
if(this.error || this.loading) {
125
await this.fetchSong();126
}, 10000);127
},128
async showDetail(station) {129
await state.app.$refs.detail.show(station);130
this.open = false;131
},132
onTouchStart(event) {133
this.touch = event.changedTouches[0];134
this.target = event.target;
231
>232
<p233
class="text-xl font-semibold text-white pb-2 overflow-hidden text-ellipsis whitespace-nowrap text-center cursor-pointer"232
@click="openDetail(station)"234
@click="showDetail(station)"235
>236
{{station.name}}237
</p>
7
export default {8
props: ['station', 'type'],9
data() {10
return { state };11
},12
components: {13
VButton,14
VIcon,
16
},17
methods: {18
$lang,16
setStation(station) {17
state.station = station;18
state.app.$refs.player.open = true;19
},20
openDetail(station) {21
state.app.$refs.detail.load(station.id);22
}19
},20
template: `21
<div>22
<div v-if="type === undefined || type === 'list'" class="w-full gap-4 group flex items-center">23
<v-image24
:station="station"29
@click="() => setStation(station)"25
@click="() => state.app.$refs.player.play(station)"26
class="w-[54px] h-[54px] min-w-[54px] cursor-pointer"27
></v-image>28
<div29
class="flex flex-col flex-1 min-w-0 cursor-pointer"34
@click="() => openDetail(station)"30
@click="() => state.app.$refs.detail.show(station)"31
>32
<p33
:title="station.name"
54
<div v-if="type === 'grid'" class="flex flex-col gap-3 group w-full min-w-full">55
<v-image56
:station="station"61
@click="() => openDetail(station)"57
@click="() => state.app.$refs.detail.show(station)"58
class="w-full aspect-square min-w-full cursor-pointer"59
></v-image>60
<p
1
import VIcon from './icon.js';3
const TYPES = {};3
export default {4
props: ['text', 'icon', 'title', 'active', 'animation', 'size', 'disabled'],5
emits: ['click'],
1
import {watch} from '/asset/lib/vue.min.js';2
import {state} from '../main.js';3
import {$lang} from '../utils.js';4
import VButton from './button.js';6
export default {7
props: ['station'],8
data() {9
return {10
state,11
synced: false,12
playing: false,13
loading: false,14
error: false15
};16
},17
components: {18
VButton19
},20
methods: {21
$lang,22
togglePlay(station) {23
if(this.synced) {24
state.app.$refs.player.setPlaying(!this.playing);25
return;26
}27
state.app.$refs.player.play(station);28
}29
},30
mounted() {31
watch([32
() => this.station,33
() => state.app.$refs.player.station,34
() => state.app.$refs.player.playing,35
() => state.app.$refs.player.loading,36
() => state.app.$refs.player.error37
], ([, value, playing, loading, error]) => {38
if(value === null || value?.id !== this.station?.id) {39
this.synced = false;40
this.playing = false;41
return;42
}43
this.synced = true;44
this.playing = playing;45
this.loading = loading;46
this.error = error;47
});48
},49
template: `50
<v-button51
:icon="[ error ? 'alert-circle' : (loading ? 'rotate-clockwise' : (playing ? 'player-pause' : 'player-play')) ]"52
@click="() => togglePlay(station)"53
:text="$lang(loading ? 'player.loading' : (playing ? 'global.pause' : 'global.listen'))"54
class="bg-zinc-900 hover:bg-white px-1"55
:animation="[ error ? '' : (loading ? 'animate-spin' : '') ]"56
:active="synced"57
></v-button>58
`59
}
1
import Vue from '/asset/lib/vue.min.js';1
import Vue, {reactive} from '/asset/lib/vue.min.js';2
import {http, $lang} from './utils.js';3
import VMenu from './component/menu.js';4
import VPlayer from './component/player.js';
13
export const SWIPE_THRESHOLD = 70;14
export const TOKEN_NAME = 'verbal-token';16
export const state = {16
export const state = reactive({17
app: null,18
tab: 'search',19
tabs: ['search', 'favorites', 'account'],
23
station: null,24
authenticated: null,25
version: VERSION26
};26
});28
(async () => {29
state.locale = await http`get::/asset/json/locale.json`();
145
<v-station :station="station"></v-station>146
</li>147
</ul>148
<div v-else class="flex flex-col gap-4 md:gap-14">148
<div v-else class="flex flex-col gap-3 md:gap-10">149
<v-carousel :title="$lang('search.latest')" :items="latest"></v-carousel>150
<v-carousel :title="$lang('search.playtime')" :items="playtime"></v-carousel>151
</div>