2024-09-26 01:05:18 +05:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { api } from "@";
|
|
|
|
import PlayIcon from "@/components/PlayIcon.vue";
|
2024-09-26 19:27:38 +05:00
|
|
|
import PauseIcon from "@/components/PauseIcon.vue";
|
2024-09-26 01:05:18 +05:00
|
|
|
import ExternalIcon from "@/components/ExternalIcon.vue";
|
|
|
|
import LocationIcon from "@/components/LocationIcon.vue"
|
|
|
|
import TicketIcon from "@/components/TicketIcon.vue";
|
|
|
|
import VinylIcon from "@/components/VinylIcon.vue";
|
|
|
|
import InfoIcon from "@/components/InfoIcon.vue";
|
|
|
|
import Tooltip from "@/components/Tooltip.vue";
|
|
|
|
import { store } from "@";
|
2024-09-26 19:27:38 +05:00
|
|
|
import { onMounted, ref } from "vue";
|
2024-09-26 01:05:18 +05:00
|
|
|
|
|
|
|
const player = store.usePlayer();
|
2024-09-26 19:27:38 +05:00
|
|
|
const isPlayable = ref(null);
|
2024-09-26 01:05:18 +05:00
|
|
|
|
|
|
|
const { stationInfo } = defineProps({
|
|
|
|
stationInfo: api.StationInfo,
|
|
|
|
});
|
|
|
|
|
|
|
|
const status = () => {
|
|
|
|
if (stationInfo.status === api.StationStatus.Receive) {
|
2024-09-26 19:27:38 +05:00
|
|
|
isPlayable.value = api.StationStatus.Online;
|
|
|
|
return;
|
2024-09-26 01:05:18 +05:00
|
|
|
}
|
|
|
|
if (stationInfo.playback === api.Playback.Stopped || stationInfo.playback === api.Playback.Paused) {
|
2024-09-26 19:27:38 +05:00
|
|
|
isPlayable.value = api.StationStatus.Offline;
|
|
|
|
return;
|
2024-09-26 01:05:18 +05:00
|
|
|
}
|
2024-09-26 19:27:38 +05:00
|
|
|
isPlayable.value = stationInfo.status;
|
2024-09-26 01:05:18 +05:00
|
|
|
};
|
2024-09-26 19:27:38 +05:00
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
status();
|
|
|
|
});
|
|
|
|
|
2024-09-26 01:05:18 +05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="flex rounded-xl m-2 bg-ctp-base">
|
|
|
|
<div class="flex items-center justify-center">
|
2024-09-26 19:27:38 +05:00
|
|
|
<div class="h-20 sm:h-36 flex rounded-l-xl aspect-square items-center justify-center bg-ctp-peach/50">
|
2024-09-26 01:05:18 +05:00
|
|
|
<VinylIcon class="p-1" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="w-full flex flex-col justify-center px-4 space-y-2">
|
|
|
|
<div class="flex h-8 sm:h-10 items-center">
|
|
|
|
<span class="flex-grow font-bold text-ctp-peach text-xl sm:text-2xl">{{ stationInfo.name }}</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="hidden sm:flex flex-col space-y-1">
|
|
|
|
<div v-if="stationInfo.location" class="flex items-center space-x-1">
|
|
|
|
<LocationIcon class="text-ctp-subtext0" />
|
|
|
|
<span class="text-ctp-subtext0">{{ stationInfo.location }}</span>
|
|
|
|
</div>
|
|
|
|
<div v-if="stationInfo.genre" class="flex items-center space-x-1">
|
|
|
|
<TicketIcon class="text-ctp-subtext0" />
|
|
|
|
<span class="text-ctp-subtext0">{{ stationInfo.genre }}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex flex-col justify-center pr-4 space-y-2">
|
|
|
|
<div class="flex items-center justify-center space-x-2">
|
|
|
|
<button
|
|
|
|
class="p-1.5 sm:p-2.5 w-8 sm:w-10 inline-flex rounded-md items-center justify-center bg-ctp-mantle hover:bg-ctp-mantle/50">
|
2024-09-26 19:27:38 +05:00
|
|
|
<Tooltip :text="stationInfo.status">
|
2024-09-26 01:05:18 +05:00
|
|
|
<InfoIcon class="text-ctp-peach" />
|
|
|
|
</Tooltip>
|
|
|
|
</button>
|
2024-09-26 19:27:38 +05:00
|
|
|
<a :href="stationInfo.url"
|
|
|
|
class="p-1.5 sm:p-2.5 w-8 sm:w-10 inline-flex rounded-md items-center justify-center bg-ctp-mantle hover:bg-ctp-mantle/50 cursor-pointer">
|
2024-09-26 01:05:18 +05:00
|
|
|
<ExternalIcon class="text-ctp-peach" />
|
2024-09-26 19:27:38 +05:00
|
|
|
</a>
|
|
|
|
<button v-if="isPlayable === api.StationStatus.Online"
|
|
|
|
@click="player.playing ? (player.station?.id === stationInfo.id ? player.pause() : player.play(stationInfo)) : player.play(stationInfo)"
|
2024-09-26 01:05:18 +05:00
|
|
|
class="p-1.5 sm:p-2.5 w-8 sm:w-10 inline-flex rounded-md items-center justify-center bg-ctp-mantle hover:bg-ctp-mantle/50">
|
2024-09-26 19:27:38 +05:00
|
|
|
<PauseIcon v-if="player.station?.id === stationInfo.id && player.playing" class="text-ctp-peach" />
|
|
|
|
<PlayIcon v-else class="text-ctp-peach" />
|
2024-09-26 01:05:18 +05:00
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</template>
|