A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
12
error: false,13
title: '- No song title available -',14
interval: null,15
resume: false15
resume: false,16
state17
};18
},19
components: {
28
this.loading = true;29
this.title = '- No song title available -';30
this.updateMediaSession();31
state.open = true;32
}33
}34
},
76
this.resume = false;77
this.updateSong();78
},77
onError(event) {79
onError() {80
this.error = true;81
this.loading = false;82
this.playing = false;
120
}, 10000);121
}122
},123
computed: {124
transform() {125
return {126
'transform': `translate(0, ${state.open ? 0 : 100}vh)`127
};128
},129
opacity() {130
return {131
'opacity': `${state.open ? 1 : 0}`,132
'pointer-events': `${state.open ? 'all' : 'none'}`133
};134
}135
},136
template: `122
<div class="sticky top-[98px] z-30 -mb-2">137
<div class="z-30">138
<div139
@click="state.open = false"140
class="fixed top-0 bottom-0 left-0 right-0 bg-black/60 transition-opacity duration-300 ease-in-out"141
:style="opacity"142
>143
</div>144
<div145
v-if="station"125
class="flex flex-col bg-black pb-6"146
ref="button"147
class="fixed w-[60px] h-[60px] bg-white rounded-full bottom-4 right-4 z-40 cursor-pointer shadow-xl"148
@click="state.open = !state.open"149
>150
<v-icon151
id="playlist"152
class="pointer-events-none"153
>154
</v-icon>155
</div>156
<div157
class="w-full flex flex-col bg-zinc-800 pb-6 rounded-t-2xl fixed left-0 right-0 bottom-0 px-4 pt-4 h-[70vh] transition-transform duration-300 ease-in-out"158
:style="transform"159
>160
<div class="w-[40px] h-[8px] bg-zinc-500 rounded-[4px] mx-auto mb-12"></div>161
<audio162
v-if="station"163
ref="player"164
controls autoplay165
:src="station.url"
173
<source :src="station.url" type="audio/ogg">174
<source :src="station.url" type="audio/aac">175
</audio>141
<div class="p-5 bg-zinc-800 rounded-xl flex gap-5 items-center relative overflow-hidden shadow-2xl z-30 flex-col sm:flex-row">142
<img143
v-if="station.icon"144
:src="station.icon"145
:alt="station.name"146
:class="{ 'animate-pulse': playing }"147
class="w-full h-full object-cover absolute top-0 left-0 right-0 bottom-0 blur-2xl opacity-30 z-0 pointer-events-none select-none"148
>149
<div class="w-[64px] h-[64px] min-w-[64px] bg-zinc-900 rounded-lg overflow-hidden z-10">176
<div v-if="station" class="flex gap-5 items-center relative flex-col sm:flex-row">177
<div class="w-[140px] h-[140px] min-w-[140px] bg-zinc-900 rounded-lg overflow-hidden z-10">178
<img179
v-if="station.icon"180
:src="station.icon"
191
<div192
class="flex flex-col flex-1 z-10 min-w-0"193
>166
<p class="text-xl font-semibold text-white pb-1 overflow-hidden text-ellipsis whitespace-nowrap select-none pointer-events-none">194
<p class="text-xl font-semibold text-white pb-1 overflow-hidden text-ellipsis whitespace-nowrap select-none pointer-events-none text-center sm:text-left">195
{{station.name}}196
</p>169
<p class="text-md text-gray-400 overflow-hidden text-ellipsis whitespace-nowrap select-none pointer-events-none">197
<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')}}199
</p>200
</div>201
<div class="inline-flex gap-4 z-10 pr-2">202
<input type="range" min="0" max="1" step="0.05" @change="setVolume">203
<v-button176
:icon="[ station.is_favorite ? 'bookmark-off' : 'bookmark' ]"177
:title="[ $lang(station.is_favorite ? 'global.unlike' : 'global.like') ]"178
:active="station.is_favorite"179
class="bg-zinc-900 hover:bg-white focus:ring-[6px] ring-white/10"180
@click="setLike(!station.is_favorite)"181
></v-button>182
<v-button204
:icon="[ error ? 'alert-circle' : (loading ? 'rotate-clockwise' : (playing ? 'player-pause' : 'player-play')) ]"205
:title="[ error ? $lang('global.error') : (playing ? $lang('global.pause') : $lang('global.play')) ]"206
:animation="[ error ? '' : (loading ? 'animate-spin' : '') ]"
210
</div>211
</div>212
</div>192
<div class="bg-gradient-to-b from-black h-2 sm:h-4"></div>213
</div>214
`215
}
12
tabs: ['search', 'favorites', 'account'],13
account: null,14
station: null,15
authenticated: false15
authenticated: false,16
open: false17
};19
const SWIPE_THRESHOLD = 70;21
(async () => {22
state.locale = await http`get::/asset/json/locale.json`();
25
el: '#app',26
data: {27
state,25
touch: null28
touch: null,29
target: null30
},31
components: {32
VMenu,
103
},104
onTouchStart(event) {105
this.touch = event.changedTouches[0];106
this.target = event.target;107
},108
onTouchEnd(event) {109
const touch = event.changedTouches[0];
113
};114
const angle = Math.atan(diff.x / diff.y) * (180 / Math.PI);115
const index = state.tabs.indexOf(state.tab);111
if(Math.abs(diff.x) > window.innerWidth / 6) {116
if(state.open) {117
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {118
if(diff.y > 0 && angle >= -30 && angle <= 30) {119
state.open = false;120
}121
}122
return;123
}124
if(Math.abs(diff.x) >= SWIPE_THRESHOLD) {125
if(diff.x > 0 && index > 0 && (angle <= -60 || angle >= 60)) {126
state.tab = state.tabs[index - 1];127
}
129
state.tab = state.tabs[index + 1];130
}131
}132
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {133
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {134
if(!state.open && this.target === this.$refs.player.$refs.button) {135
if(diff.y < 0 && angle >= -30 && angle <= 30) {136
state.open = true;137
}138
}139
}140
}141
}142
},143
computed: {
158
class="px-4 sm:px-10 max-w-[1200px] mx-auto flex flex-col min-h-[100vh] max-h-[100vh] overflow-hidden"159
>160
<v-menu :state="state"></v-menu>139
<v-player v-if="state.authenticated" :station="state.station"></v-player>161
<div class="flex flex-1 gap-[32px] sm:gap-[5rem] overflow-y-clip transition-transform md:transition-none" :style="styles">162
<v-search v-if="state.authenticated" ref="search" :state="state"></v-search>163
<v-favorites v-if="state.authenticated" ref="favorites" :state="state"></v-favorites>164
<v-account v-if="state.authenticated" :state="state"></v-account>165
</div>166
<v-player ref="player" v-if="state.authenticated" :station="state.station"></v-player>167
<v-popup ref="popup"></v-popup>168
</div>169
`