diff --git a/crates/frontend/src/store.ts b/crates/frontend/src/store.ts
index d6dbc74..069a7a5 100644
--- a/crates/frontend/src/store.ts
+++ b/crates/frontend/src/store.ts
@@ -6,6 +6,12 @@ import { api } from "@";
type TimerId = number;
+const setAsyncTimeout = (ms: number) => {
+ return new Promise((resolve) => {
+ setTimeout(resolve, ms * 1000);
+ });
+};
+
export const usePlayer = defineStore("player", () => {
const stations: Ref
= ref(null);
const station: Ref = ref(null);
@@ -33,9 +39,24 @@ export const usePlayer = defineStore("player", () => {
};
const update = async () => {
+ if (station.value.status !== api.StationStatus.Receive) {
+ songInfo.value = null;
+ return;
+ }
+
await refreshSongInfo();
+
clearTimeout(updateTimer.value);
- updateTimer.value = setTimeout(update, (songInfo.value.duration - songInfo.value.elapsed) * 1000);
+
+ if (songInfo.value.duration) {
+ updateTimer.value = await setAsyncTimeout(songInfo.value.duration - songInfo.value.elapsed);
+ } else {
+ updateTimer.value = await setAsyncTimeout(5);
+ }
+
+ if (playing.value) {
+ await update();
+ }
};
const play = (_station: api.StationInfo | null = null) => {
diff --git a/crates/frontend/tailwind.config.js b/crates/frontend/tailwind.config.js
index b56e0f7..517b83c 100644
--- a/crates/frontend/tailwind.config.js
+++ b/crates/frontend/tailwind.config.js
@@ -13,11 +13,20 @@ export default {
"100%": {
"background-position": "200% 0",
}
+ },
+ "spin": {
+ "from": {
+ "transform": "rotate(0deg)",
+ },
+ "to": {
+ "transform": "rotate(360deg)",
+ }
}
},
animation: {
"border-spin": "border-spin 7s linear infinite",
- "border-roll": "border-roll 5s linear infinite"
+ "border-roll": "border-roll 5s linear infinite",
+ "spin-slow": "spin 2s linear infinite",
}
},
},