A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
31
},32
},33
template: `34
<div class="sticky top-[98px] z-30 -mb-6 sm:-mb-10">34
<div class="sticky top-[98px] z-30">35
<div36
v-if="station"37
class="flex flex-col bg-black pb-6"38
>39
<audio controls autoplay :src="station.stream_url" class="select-none pointer-events-none w-0 h-0 opacity-0"></audio>40
<div class="p-5 bg-zinc-800 rounded-xl flex gap-5 items-center relative overflow-hidden shadow-2xl z-30">41
<img42
v-if="station.favicon"
43
></v-icon>44
</div>45
<div class="flex flex-col flex-1 min-w-0">46
<p class="text-lg font-medium text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap">{{station.name}}</p>46
<p :title="station.name" class="text-lg font-medium text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap">{{station.name}}</p>47
<span class="text-md text-gray-400 overflow-hidden flex gap-2 sm:gap-3">48
<span49
v-if="station.country"
1
import {http} from './utils.js';2
import VMenu from './component/menu.js';3
import VPlayer from './component/player.js';4
import VSearch from './page/search.js';5
import VFavorites from './page/favorites.js';6
import VAccount from './page/account.js';
27
VMenu,28
VSearch,29
VFavorites,29
VAccount30
VAccount,31
VPlayer32
},33
mounted() {34
document.body.style.display = '';
37
},38
methods: {39
async init() {40
window.app = this;41
state.account = await http`get::/api/account`();42
// document.addEventListener('keyup', this.onKey);43
document.addEventListener('scroll', this.onScroll);44
document.addEventListener('wheel', this.onScroll);45
},46
// onKey(event) {47
// const {code, ctrlKey, shiftKey, altKey} = event;48
// if(!ctrlKey && !shiftKey && !altKey) {49
// if(code === 'KeyS') state.tab = 'search';50
// if(code === 'KeyF') state.tab = 'favorites';51
// if(code === 'KeyA') state.tab = 'account';52
// }53
// },54
onScroll() {55
if(window.innerHeight + window.pageYOffset >= document.body.offsetHeight - 200) {56
this.$refs.search.doSearchMore();57
}58
}59
},60
template: `61
<div class="px-4 sm:px-10 pb-8 sm:pb-[100px] max-w-[800px] mx-auto flex flex-col">62
<v-menu :state="state"></v-menu>44
<v-search :state="state"></v-search>63
<v-player :station="state.station"></v-player>64
<v-search ref="search" :state="state"></v-search>65
<v-favorites ref="favorites" :state="state"></v-favorites>66
<v-account :state="state"></v-account>67
</div>68
`69
});70
})();
1
import {$lang, http} from '../utils.js';2
import VIcon from '../element/icon.js';3
import VPlayer from '../component/player.js';3
import VTab from '../component/tab.js';4
import VStation from '../component/station.js';
14
components: {15
VIcon,16
VTab,18
VPlayer,17
VStation18
},19
methods: {
31
},32
template: `33
<v-tab id="favorites" :tab="state.tab">36
<v-player :station="state.station"></v-player>34
<ul class="flex flex-col">35
<li36
:key="station.id"
1
import {$lang, http} from '../utils.js';2
import VIcon from '../element/icon.js';3
import VPlayer from '../component/player.js';3
import VTab from '../component/tab.js';4
import VStation from '../component/station.js';
19
components: {20
VIcon,21
VTab,23
VPlayer,22
VStation23
},24
methods: {
26
async doSearch() {27
this.results = [];28
this.loading = true;29
this.more = true;30
this.query.page = 0;31
const result = await http`get::/api/search`(this.query);32
this.loading = false;33
this.results = result;34
},35
async doSearchMore() {36
if(this.loading) return;37
if(!this.more) return;38
this.query.page++;39
this.loading = true;40
const result = await http`get::/api/search`(this.query);41
this.loading = false;42
if(result.length == 0) {43
this.more = false;44
}45
this.results.push(...result);46
}47
},48
mounted() {
50
},51
template: `52
<v-tab id="search" :tab="state.tab" @show="doSearch">41
<v-player :station="state.station"></v-player>53
<input54
v-model="query.name"55
@keyup.enter="doSearch"
85
>86
{{$lang('search.list.end')}}87
</div>88
<div89
v-if="results.length == 0"90
class="text-zinc-400 text-md mx-auto pb-6"91
>92
{{$lang('search.list.empty')}}93
</div>94
</v-tab>95
`96
}
32
impl RadioBrowserApi {33
pub async fn search(search: Search) -> Result<Vec<rest::Station>> {34
let uri = format!("/json/stations/search?{}", &search);35
let mut response = match RadioBrowserApi::fetch(&uri).await {36
Ok(response) => response,37
Err(err) => return Err(err),38
};35
let mut response = RadioBrowserApi::fetch(&uri).await?;36
match response.body_json::<Vec<rest::Station>>().await {37
Ok(data) => Ok(data),38
Err(err) => Err(Error::new(ErrorKind::Parse, &err.to_string())),
42
pub async fn by_uuids(uuids: Vec<String>) -> Result<Vec<rest::Station>> {43
let uri = format!("/json/stations/byuuid?uuids={}", &uuids.join(","));47
let mut response = match RadioBrowserApi::fetch(&uri).await {48
Ok(response) => response,49
Err(err) => return Err(err),50
};44
let mut response = RadioBrowserApi::fetch(&uri).await?;45
match response.body_json::<Vec<rest::Station>>().await {46
Ok(data) => Ok(data),47
Err(err) => Err(Error::new(ErrorKind::Parse, &err.to_string())),
21
"player.loading": "Loading...",22
"player.no-song-title": "- No song title available -",24
"search.input.placeholder": "Search for station",24
"search.input.placeholder": "Search for stations",25
"search.list.end": "You've reached the end",26
"search.list.empty": "No results found",28
"account.settings": "Settings",29
"account.username": "Username",
61
"search.input.placeholder": "Suche nach Sender",62
"search.list.end": "Du hast das Ende erreicht",63
"search.list.empty": "Keine Ergebnisse gefunden",65
"account.settings": "Einstellungen",66
"account.username": "Nutzername",