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-[64px] h-[64px] 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"
189
></v-icon>190
</div>191
<div164
class="flex flex-col flex-1 z-10 min-w-0"192
class="flex flex-col flex-1 z-10 min-w-0 max-w-full"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
}
4
export default {5
props: ['title', 'description', 'actions'],6
data() {7
return {8
show: false9
};10
},11
components: {12
VButton13
},
18
this.title = title;19
this.description = description;20
this.actions = actions;16
this.$refs.dialog.show();21
this.show = true;22
},23
close() {19
this.title = null;20
this.description = null;21
this.actions = null;22
this.$refs.dialog.close();24
this.show = false;25
}26
},25
mounted() {26
this.close();27
computed: {28
opacity() {29
return {30
'opacity': `${this.show ? 1 : 0}`,31
'pointer-events': `${this.show ? 'all' : 'none'}`32
};33
},34
transform() {35
return {36
'opacity': `${this.show ? 1 : 0}`,37
'pointer-events': `${this.show ? 'all' : 'none'}`,38
'transform': `translate(-50%, calc(-50% + ${this.show ? '0' : '30'}px))`39
};40
}41
},42
template: `29
<dialog ref="dialog" class="z-40 fixed w-full h-full bg-black/80">30
<div class="flex flex-col fixed left-[50%] top-[50%] -translate-y-[50%] -translate-x-[50%] rounded-lg sm:rounded-md bg-zinc-900 w-[500px] max-w-[85vw] p-6 sm:p-8 pt-10 sm:pt-8">43
<div class="z-40">44
<div45
class="fixed top-0 bottom-0 left-0 right-0 bg-black/60 transition-opacity duration-300 ease-in-out"46
:style="opacity"47
>48
</div>49
<div50
class="z-50 flex flex-col fixed left-[50%] top-[50%] -translate-y-[50%] -translate-x-[50%] rounded-lg sm:rounded-md bg-zinc-900 w-[500px] max-w-[85vw] p-6 sm:p-8 pt-10 sm:pt-8 transition-all duration-300 ease-in-out"51
:style="transform"52
>53
<h3 class="text-white text-[24px] font-bold pb-4 text-center sm:text-left">{{title}}</h3>54
<p class="text-md text-gray-400 text-center sm:text-left" v-html="description"></p>55
<div class="flex gap-2 w-full justify-end">
61
></v-button>62
</div>63
</div>42
</dialog>64
</div>65
`66
}
6
import VFavorites from './page/favorites.js';7
import VAccount from './page/account.js';9
const VERSION = 'dev-{{version}}';10
const SWIPE_THRESHOLD = 70;12
export const state = {13
app: null,14
tab: 'search',15
tabs: ['search', 'favorites', 'account'],16
account: null,17
station: null,15
authenticated: false18
authenticated: false,19
open: false,20
version: VERSION21
};23
(async () => {
27
el: '#app',28
data: {29
state,25
touch: null30
touch: null,31
target: null32
},33
components: {34
VMenu,
52
// ignore53
}54
if(state.account === null) {49
// TODO: create account or authenticate55
this.$refs.popup.open({56
title: $lang('global.welcome'),57
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.',58
actions: [59
{60
icon: 'check',61
title: $lang('global.continue'),62
handle: () => {63
localStorage.setItem('verbal-token', 'test-token');64
window.location.reload();65
}66
}67
]68
});69
return;70
}71
state.authenticated = true;
118
},119
onTouchStart(event) {120
this.touch = event.changedTouches[0];121
this.target = event.target;122
},123
onTouchEnd(event) {124
const touch = event.changedTouches[0];
128
};129
const angle = Math.atan(diff.x / diff.y) * (180 / Math.PI);130
const index = state.tabs.indexOf(state.tab);111
if(Math.abs(diff.x) > window.innerWidth / 6) {131
if(state.open) {132
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {133
if(diff.y > 0 && angle >= -30 && angle <= 30) {134
state.open = false;135
}136
}137
return;138
}139
if(Math.abs(diff.x) >= SWIPE_THRESHOLD) {140
if(diff.x > 0 && index > 0 && (angle <= -60 || angle >= 60)) {141
state.tab = state.tabs[index - 1];142
}
144
state.tab = state.tabs[index + 1];145
}146
}147
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {148
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {149
if(!state.open && this.target === this.$refs.player.$refs.button) {150
if(diff.y < 0 && angle >= -30 && angle <= 30) {151
state.open = true;152
}153
}154
}155
}156
}157
},158
computed: {
173
class="px-4 sm:px-10 max-w-[1200px] mx-auto flex flex-col min-h-[100vh] max-h-[100vh] overflow-hidden"174
>175
<v-menu :state="state"></v-menu>139
<v-player v-if="state.authenticated" :station="state.station"></v-player>176
<div class="flex flex-1 gap-[32px] sm:gap-[5rem] overflow-y-clip transition-transform md:transition-none" :style="styles">177
<v-search v-if="state.authenticated" ref="search" :state="state"></v-search>178
<v-favorites v-if="state.authenticated" ref="favorites" :state="state"></v-favorites>179
<v-account v-if="state.authenticated" :state="state"></v-account>180
</div>181
<v-player ref="player" v-if="state.authenticated" :station="state.station"></v-player>182
<v-popup ref="popup"></v-popup>183
</div>184
`
11
},12
template: `13
<v-tab id="account" :tab="state.tab">14
<div class="sticky top-[98px] z-30 -mb-6">15
<div class="bg-gradient-to-b from-black h-2 sm:h-4"></div>14
<div class="pb-8 sm:pb-[100px] pt-2">15
<p class="text-md text-gray-400 text-center">Verbal</p>16
<p class="text-md text-gray-400 text-center">{{state.version}}</p>17
<p class="text-md text-gray-400 text-center pt-2">18
Created by19
<a class="text-gray-200 hover:underline font-bold" href="https://github.com/typable" target="_blank">@typable</a>20
</p>21
</div>22
</v-tab>23
`
22
const headers = {23
'content-type': 'application/json',24
}25
const token = localStorage.getItem('verbal-token') ?? 'test-token';25
const token = localStorage.getItem('verbal-token');26
if(token) {27
headers['verbal-token'] = token;28
}
5
version=$(cat ./.version)6
sed -i -e "s/{{version}}/$version/g" www/worker.js7
sed -i -e "s/{{version}}/$version/g" app/main.js
21
"global.report": "Report issue",22
"global.error": "Error",23
"global.error.message": "An error occured! Please try again later. If the error persists feel free to let us know.<br><br>Message: {0}",24
"global.welcome": "Welcome",25
"player.loading": "Loading...",26
"player.no-song-title": "- No song title available -",27
"search.input.placeholder": "Search for stations",
60
"global.report": "Fehler melden",61
"global.error": "Fehler",62
"global.error.message": "Ein Fehler ist aufgetreten! Bitte versuche es später erneut. Wenn der Fehler weiterhin besteht, fühle dich frei dies uns mitzuteilen.<br><br>Nachricht: {0}",63
"global.welcome": "Willkommen",64
"player.loading": "Laden...",65
"player.no-song-title": "- Song Titel nicht verfügbar -",66
"search.input.placeholder": "Suche nach Sender",