Compare commits
1 Commits
offline-mo
...
f777873432
| Author | SHA1 | Date | |
|---|---|---|---|
| f777873432 |
4327
package-lock.json
generated
Normal file
4327
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -15,34 +15,33 @@
|
|||||||
"generate_iconfont_subset": "cd scripts && bash ./generate_iconfont_subset.sh"
|
"generate_iconfont_subset": "cd scripts && bash ./generate_iconfont_subset.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sveltejs/kit": "^2.55.0",
|
"@sveltejs/kit": "^2.17.1",
|
||||||
"@types/bun": "^1.3.10",
|
"@types/bun": "^1.2.2",
|
||||||
"@types/node": "^25.5.0",
|
"@types/node": "^20.17.17",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||||
"@typescript-eslint/parser": "^8.57.0",
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
"carta-md": "^4.11.1",
|
"carta-md": "^4.6.7",
|
||||||
"dotenv": "^16.6.1",
|
"dotenv": "^16.4.7",
|
||||||
"eslint": "^10.0.3",
|
"eslint": "^8.57.1",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^8.10.0",
|
||||||
"eslint-plugin-svelte": "^3.15.2",
|
"eslint-plugin-svelte": "^2.46.1",
|
||||||
"fontkit": "^2.0.4",
|
"fontkit": "^2.0.4",
|
||||||
"isomorphic-dompurify": "^3.3.0",
|
"isomorphic-dompurify": "^2.21.0",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.4.2",
|
||||||
"prettier-plugin-svelte": "^3.5.1",
|
"prettier-plugin-svelte": "^3.3.3",
|
||||||
"sqids": "0.3.0",
|
"sqids": "0.3.0",
|
||||||
"svelte": "^5.53.12",
|
"svelte": "^5.19.9",
|
||||||
"svelte-check": "^4.4.5",
|
"svelte-check": "^4.1.4",
|
||||||
"svelte-select": "^5.8.3",
|
"svelte-select": "^5.8.3",
|
||||||
"tslib": "^2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.7.3",
|
||||||
"vite": "^8.0.0"
|
"vite": "^5.4.14"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-node": "^5.5.4",
|
"@sveltejs/vite-plugin-svelte": "^4.0.4",
|
||||||
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
"svelte-adapter-bun": "https://github.com/gornostay25/svelte-adapter-bun",
|
||||||
"svelte-adapter-bun": "^1.0.1",
|
"typescript-svelte-plugin": "^0.3.45"
|
||||||
"typescript-svelte-plugin": "^0.3.50"
|
|
||||||
},
|
},
|
||||||
"trustedDependencies": [
|
"trustedDependencies": [
|
||||||
"svelte-adapter-bun"
|
"svelte-adapter-bun"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ fontFile="$(basename "$fontUrl")"
|
|||||||
unicodePoints=(
|
unicodePoints=(
|
||||||
"61-7a,5f" # ascii lowercase + underscore
|
"61-7a,5f" # ascii lowercase + underscore
|
||||||
"e2c4" # file_download
|
"e2c4" # file_download
|
||||||
"e872" # delete
|
|
||||||
"e037" # play_arrow
|
"e037" # play_arrow
|
||||||
"e034" # pause
|
"e034" # pause
|
||||||
"e04f" # volume_off
|
"e04f" # volume_off
|
||||||
|
|||||||
36
src/lib/database.js
Normal file
36
src/lib/database.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { Database } from 'bun:sqlite';
|
||||||
|
|
||||||
|
const dbName = './db/strimserve.db';
|
||||||
|
|
||||||
|
// Create a new database object and initialize it with the schema
|
||||||
|
const db = new Database(dbName);
|
||||||
|
|
||||||
|
export function getStreams() {
|
||||||
|
const indexData = db
|
||||||
|
.prepare(
|
||||||
|
'SELECT id, stream_date, title, tags, length_seconds ' + 'FROM Stream ORDER BY id DESC'
|
||||||
|
)
|
||||||
|
.all();
|
||||||
|
indexData.forEach((stream) => {
|
||||||
|
stream['stream_date'] = Date.parse(stream['stream_date']);
|
||||||
|
stream['tags'] = JSON.parse(stream['tags']);
|
||||||
|
});
|
||||||
|
return indexData;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getStreamInfo(streamId) {
|
||||||
|
const streamData = db
|
||||||
|
.prepare(
|
||||||
|
'SELECT id, stream_date, filename, ' +
|
||||||
|
'format, title, description, tags, ' +
|
||||||
|
'length_seconds, tracks FROM Stream ' +
|
||||||
|
'WHERE id = ?'
|
||||||
|
)
|
||||||
|
.get(streamId);
|
||||||
|
if (streamData) {
|
||||||
|
streamData['stream_date'] = Date.parse(streamData['stream_date']);
|
||||||
|
streamData['tracks'] = JSON.parse(streamData['tracks']);
|
||||||
|
streamData['tags'] = JSON.parse(streamData['tags']);
|
||||||
|
}
|
||||||
|
return streamData;
|
||||||
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import { Database } from 'bun:sqlite';
|
|
||||||
import type { Stream, StreamSummary } from './types.ts';
|
|
||||||
|
|
||||||
const dbName = './db/strimserve.db';
|
|
||||||
|
|
||||||
// Create a new database object and initialize it with the schema
|
|
||||||
const db = new Database(dbName);
|
|
||||||
|
|
||||||
export function getStreams(): StreamSummary[] {
|
|
||||||
const indexData = db
|
|
||||||
.prepare(
|
|
||||||
'SELECT id, stream_date, filename, title, tags, length_seconds ' + 'FROM Stream ORDER BY id DESC'
|
|
||||||
)
|
|
||||||
.all() as Record<string, unknown>[];
|
|
||||||
return indexData.map((stream) => ({
|
|
||||||
id: stream.id as string,
|
|
||||||
stream_date: Date.parse(stream.stream_date as string),
|
|
||||||
filename: stream.filename as string,
|
|
||||||
title: stream.title as string | null,
|
|
||||||
tags: JSON.parse(stream.tags as string) as string[],
|
|
||||||
length_seconds: stream.length_seconds as number
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getStreamInfo(streamId: string): Stream | null {
|
|
||||||
const streamData = db
|
|
||||||
.prepare(
|
|
||||||
'SELECT id, stream_date, filename, ' +
|
|
||||||
'format, title, description, tags, ' +
|
|
||||||
'length_seconds, tracks FROM Stream ' +
|
|
||||||
'WHERE id = ?'
|
|
||||||
)
|
|
||||||
.get(streamId) as Record<string, unknown> | null;
|
|
||||||
if (!streamData) return null;
|
|
||||||
return {
|
|
||||||
id: streamData.id as string,
|
|
||||||
stream_date: Date.parse(streamData.stream_date as string),
|
|
||||||
filename: streamData.filename as string,
|
|
||||||
format: streamData.format as string,
|
|
||||||
title: streamData.title as string | null,
|
|
||||||
description: streamData.description as string | null,
|
|
||||||
tags: JSON.parse(streamData.tags as string) as string[],
|
|
||||||
length_seconds: streamData.length_seconds as number,
|
|
||||||
tracks: JSON.parse(streamData.tracks as string)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
85
src/lib/stores.js
Normal file
85
src/lib/stores.js
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { writable, get } from 'svelte/store';
|
||||||
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
|
export const currentStream = writable({});
|
||||||
|
export const currentSongIndex = writable(null);
|
||||||
|
|
||||||
|
export const favoritedStreams = writable(
|
||||||
|
new Set(JSON.parse((browser && localStorage.getItem('favoritedStreams')) || '[]'))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (browser) {
|
||||||
|
favoritedStreams.subscribe((val) => {
|
||||||
|
localStorage.setItem('favoritedStreams', JSON.stringify(Array.from(val)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export const tagList = [
|
||||||
|
'acoustic',
|
||||||
|
'electronic',
|
||||||
|
'orchestral',
|
||||||
|
'rock',
|
||||||
|
'pop',
|
||||||
|
'metal',
|
||||||
|
'aggressive',
|
||||||
|
'folk',
|
||||||
|
'jazzy',
|
||||||
|
'dance.music',
|
||||||
|
'untz',
|
||||||
|
'breakbeats',
|
||||||
|
'electronica',
|
||||||
|
'chiptune',
|
||||||
|
'left.field',
|
||||||
|
'denpa',
|
||||||
|
'vocaloid',
|
||||||
|
'funky',
|
||||||
|
'lush',
|
||||||
|
'noisy',
|
||||||
|
'psychedelic',
|
||||||
|
'dark',
|
||||||
|
'calm',
|
||||||
|
'moody',
|
||||||
|
'uplifting'
|
||||||
|
];
|
||||||
|
|
||||||
|
let timestampList;
|
||||||
|
|
||||||
|
// utility
|
||||||
|
|
||||||
|
function locationOf(element, array, start, end) {
|
||||||
|
start = start || 0;
|
||||||
|
end = end || array.length;
|
||||||
|
var pivot = parseInt(start + (end - start) / 2, 10);
|
||||||
|
if (end - start <= 1 || array[pivot] === element) return pivot;
|
||||||
|
if (array[pivot] < element) {
|
||||||
|
return locationOf(element, array, pivot, end);
|
||||||
|
} else {
|
||||||
|
return locationOf(element, array, start, pivot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// exported methods
|
||||||
|
|
||||||
|
export function getSongAtTime(currentTime) {
|
||||||
|
return locationOf(currentTime, timestampList) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// less operations needed when doing regular lookups
|
||||||
|
export function updateCurrentSong(currentTime, songIndex) {
|
||||||
|
function updateCurrentSongRecurse(songIndex) {
|
||||||
|
if (currentTime >= timestampList[songIndex + 2]) {
|
||||||
|
return updateCurrentSongRecurse(songIndex + 1);
|
||||||
|
} else if (currentTime < timestampList[songIndex + 1]) {
|
||||||
|
return updateCurrentSongRecurse(songIndex - 1);
|
||||||
|
}
|
||||||
|
return songIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentSongIndex.set(updateCurrentSongRecurse(songIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateCurrentStream(stream) {
|
||||||
|
currentStream.set(stream);
|
||||||
|
timestampList = [-Infinity, ...stream.tracks.map((track) => track[0]), Infinity];
|
||||||
|
currentSongIndex.set(0);
|
||||||
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { browser } from '$app/environment';
|
|
||||||
import { SvelteSet } from 'svelte/reactivity';
|
|
||||||
|
|
||||||
export const favoritedStreams = new SvelteSet<string>(
|
|
||||||
JSON.parse((browser && localStorage.getItem('favoritedStreams')) || '[]')
|
|
||||||
);
|
|
||||||
$effect.root(() => {
|
|
||||||
$effect(() => {
|
|
||||||
localStorage.setItem('favoritedStreams', JSON.stringify(Array.from(favoritedStreams)));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export const tagList = [
|
|
||||||
'acoustic',
|
|
||||||
'electronic',
|
|
||||||
'orchestral',
|
|
||||||
'rock',
|
|
||||||
'pop',
|
|
||||||
'metal',
|
|
||||||
'aggressive',
|
|
||||||
'folk',
|
|
||||||
'jazzy',
|
|
||||||
'dance.music',
|
|
||||||
'untz',
|
|
||||||
'breakbeats',
|
|
||||||
'electronica',
|
|
||||||
'chiptune',
|
|
||||||
'left.field',
|
|
||||||
'denpa',
|
|
||||||
'vocaloid',
|
|
||||||
'funky',
|
|
||||||
'lush',
|
|
||||||
'noisy',
|
|
||||||
'psychedelic',
|
|
||||||
'dark',
|
|
||||||
'calm',
|
|
||||||
'moody',
|
|
||||||
'uplifting'
|
|
||||||
];
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
import { browser } from '$app/environment';
|
|
||||||
import { SvelteSet, SvelteMap } from 'svelte/reactivity';
|
|
||||||
import type { StreamSummary } from './types.ts';
|
|
||||||
|
|
||||||
const STORAGE_KEY = 'cachedStreams';
|
|
||||||
|
|
||||||
export const cached = new SvelteSet<string>(
|
|
||||||
browser ? JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]') : []
|
|
||||||
);
|
|
||||||
export const downloading = new SvelteMap<string, number>();
|
|
||||||
|
|
||||||
if (browser) {
|
|
||||||
$effect.root(() => {
|
|
||||||
$effect(() => {
|
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify([...cached]));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function download(stream: StreamSummary) {
|
|
||||||
const res = await fetch(`/media/tracks/${stream.filename}`);
|
|
||||||
if (!res.ok || !res.body) throw new Error('Download failed');
|
|
||||||
|
|
||||||
const total = Number(res.headers.get('content-length') || 0);
|
|
||||||
const reader = res.body.getReader();
|
|
||||||
const chunks: Uint8Array[] = [];
|
|
||||||
let received = 0;
|
|
||||||
|
|
||||||
downloading.set(stream.id, 0);
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
const { done, value } = await reader.read();
|
|
||||||
if (done) break;
|
|
||||||
chunks.push(value);
|
|
||||||
received += value.length;
|
|
||||||
if (total) downloading.set(stream.id, Math.round((received / total) * 100));
|
|
||||||
}
|
|
||||||
|
|
||||||
const root = await navigator.storage.getDirectory();
|
|
||||||
const handle = await root.getFileHandle(stream.id, { create: true });
|
|
||||||
const writable = await handle.createWritable();
|
|
||||||
await writable.write(new Blob(chunks));
|
|
||||||
await writable.close();
|
|
||||||
|
|
||||||
downloading.delete(stream.id);
|
|
||||||
cached.add(stream.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function remove(streamId: string) {
|
|
||||||
const root = await navigator.storage.getDirectory();
|
|
||||||
await root.removeEntry(streamId);
|
|
||||||
cached.delete(streamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getUrl(streamId: string): Promise<string | null> {
|
|
||||||
if (!cached.has(streamId)) return null;
|
|
||||||
try {
|
|
||||||
const root = await navigator.storage.getDirectory();
|
|
||||||
const handle = await root.getFileHandle(streamId);
|
|
||||||
const file = await handle.getFile();
|
|
||||||
return URL.createObjectURL(file);
|
|
||||||
} catch {
|
|
||||||
cached.delete(streamId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
import { createContext } from 'svelte';
|
|
||||||
import type { Stream, StreamSummary } from './types.ts';
|
|
||||||
|
|
||||||
export class StreamContext {
|
|
||||||
streams: StreamSummary[];
|
|
||||||
current = $state<Stream | null>(null);
|
|
||||||
songIndex = $state<number | null>(null);
|
|
||||||
#timestamps: number[] = [];
|
|
||||||
|
|
||||||
constructor(streams: StreamSummary[]) {
|
|
||||||
this.streams = streams;
|
|
||||||
}
|
|
||||||
|
|
||||||
setCurrent(stream: Stream) {
|
|
||||||
this.current = stream;
|
|
||||||
this.#timestamps = [-Infinity, ...stream.tracks.map((t) => t[0]), Infinity];
|
|
||||||
this.songIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
clearCurrent() {
|
|
||||||
this.current = null;
|
|
||||||
this.songIndex = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
getSongAtTime(time: number): number {
|
|
||||||
return this.#locationOf(time, this.#timestamps) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCurrentSong(currentTime: number, songIndex: number) {
|
|
||||||
const ts = this.#timestamps;
|
|
||||||
const recurse = (idx: number): number => {
|
|
||||||
if (currentTime >= ts[idx + 2]) return recurse(idx + 1);
|
|
||||||
if (currentTime < ts[idx + 1]) return recurse(idx - 1);
|
|
||||||
return idx;
|
|
||||||
};
|
|
||||||
this.songIndex = recurse(songIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
#locationOf(element: number, array: number[], start = 0, end = array.length): number {
|
|
||||||
const pivot = Math.floor(start + (end - start) / 2);
|
|
||||||
if (end - start <= 1 || array[pivot] === element) return pivot;
|
|
||||||
if (array[pivot] < element) return this.#locationOf(element, array, pivot, end);
|
|
||||||
return this.#locationOf(element, array, start, pivot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const [getStreamContext, setStreamContext] = createContext<StreamContext>();
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/** A track entry: [timestamp_seconds, artist, title] */
|
|
||||||
export type Track = [number, string, string];
|
|
||||||
|
|
||||||
/** The summary shape used in sidebar listings. */
|
|
||||||
export interface StreamSummary {
|
|
||||||
id: string;
|
|
||||||
stream_date: number;
|
|
||||||
filename: string;
|
|
||||||
title: string | null;
|
|
||||||
tags: string[];
|
|
||||||
length_seconds: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The full stream shape used on the detail/player page. */
|
|
||||||
export interface Stream extends StreamSummary {
|
|
||||||
format: string;
|
|
||||||
description: string | null;
|
|
||||||
tracks: Track[];
|
|
||||||
}
|
|
||||||
37
src/lib/utils.js
Normal file
37
src/lib/utils.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import Sqids from 'sqids';
|
||||||
|
|
||||||
|
let sqids = new Sqids({ minLength: 6, alphabet: 'abcdefghijklmnopqrstuvwxyz0123456789' });
|
||||||
|
|
||||||
|
export function hashcode(str) {
|
||||||
|
for (var i = 0, h = 9; i < str.length; ) h = Math.imul(h ^ str.charCodeAt(i++), 9 ** 9);
|
||||||
|
return h ^ (h >>> 9);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for mnemonic display
|
||||||
|
export function shorthandCode(str) {
|
||||||
|
return sqids.encode([hashcode(str) & 0xffff]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for tag display
|
||||||
|
export function hashColor(str) {
|
||||||
|
const hash = hashcode(str);
|
||||||
|
return `hsl(${hash % 360}, ${65 + (hash % 30) + 1}%, ${85 + (hash % 10) + 1}%)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatSecondsToHms(s) {
|
||||||
|
s = Number(s);
|
||||||
|
var h = Math.floor(s / 3600);
|
||||||
|
var m = Math.ceil((s % 3600) / 60);
|
||||||
|
|
||||||
|
var hDisplay = h > 0 ? h + (h == 1 ? ' hr' : ' hrs') + (m > 0 ? ', ' : '') : '';
|
||||||
|
var mDisplay = m > 0 ? m + (m == 1 ? ' min' : ' mins') : '';
|
||||||
|
return hDisplay + mDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatDate(unix_timestamp) {
|
||||||
|
return new Date(unix_timestamp).toISOString().split('T')[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatTrackTime(s) {
|
||||||
|
return new Date(s * 1000).toISOString().slice(11, 19);
|
||||||
|
}
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import Sqids from 'sqids';
|
|
||||||
|
|
||||||
const sqids = new Sqids({ minLength: 6, alphabet: 'abcdefghijklmnopqrstuvwxyz0123456789' });
|
|
||||||
|
|
||||||
export function hashcode(str: string): number {
|
|
||||||
let h = 9;
|
|
||||||
for (let i = 0; i < str.length; ) h = Math.imul(h ^ str.charCodeAt(i++), 9 ** 9);
|
|
||||||
return h ^ (h >>> 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
// for mnemonic display
|
|
||||||
export function shorthandCode(str: string): string {
|
|
||||||
return sqids.encode([hashcode(str) & 0xffff]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// for tag display
|
|
||||||
export function hashColor(str: string): string {
|
|
||||||
const hash = hashcode(str);
|
|
||||||
return `hsl(${hash % 360}, ${65 + (hash % 30) + 1}%, ${85 + (hash % 10) + 1}%)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function formatSecondsToHms(s: number): string {
|
|
||||||
s = Number(s);
|
|
||||||
const h = Math.floor(s / 3600);
|
|
||||||
const m = Math.ceil((s % 3600) / 60);
|
|
||||||
|
|
||||||
const hDisplay = h > 0 ? h + (h == 1 ? ' hr' : ' hrs') + (m > 0 ? ', ' : '') : '';
|
|
||||||
const mDisplay = m > 0 ? m + (m == 1 ? ' min' : ' mins') : '';
|
|
||||||
return hDisplay + mDisplay;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function formatDate(unix_timestamp: number): string {
|
|
||||||
return new Date(unix_timestamp).toISOString().split('T')[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function formatTrackTime(s: number): string {
|
|
||||||
return new Date(s * 1000).toISOString().slice(11, 19);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getStreams } from '$lib/database.ts';
|
import { getStreams } from '$lib/database.js';
|
||||||
|
|
||||||
export function load() {
|
export function load() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Sidebar from './Sidebar.svelte';
|
import Sidebar from './Sidebar.svelte';
|
||||||
import Footer from './Footer.svelte';
|
import Footer from './Footer.svelte';
|
||||||
import { setStreamContext, StreamContext } from '$lib/streamContext.svelte.ts';
|
let { data, children } = $props();
|
||||||
|
|
||||||
// streams are grabbed from the server here, then accessed throughout the rest
|
|
||||||
// of the components through the svelte context api
|
|
||||||
const { data, children } = $props();
|
|
||||||
setStreamContext(new StreamContext(data.streams));
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="mainContainer">
|
<div id="mainContainer">
|
||||||
<div id="sidebar" class="panel"><Sidebar /></div>
|
<div id="sidebar" class="panel"><Sidebar streams={data.streams} /></div>
|
||||||
<div id="footer" class="panel-alt"><Footer /></div>
|
<div id="footer" class="panel-alt"><Footer /></div>
|
||||||
<div id="content">{@render children?.()}</div>
|
<div id="content">{@render children?.()}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { untrack } from 'svelte';
|
import { untrack } from 'svelte';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { favoritedStreams } from '$lib/stores.svelte.ts';
|
import { currentStream, favoritedStreams } from '$lib/stores.js';
|
||||||
import * as streamCache from '$lib/streamCache.svelte.ts';
|
import { hashColor, shorthandCode, formatSecondsToHms, formatDate } from '$lib/utils.js';
|
||||||
import { getStreamContext } from '$lib/streamContext.svelte.ts';
|
|
||||||
import type { StreamSummary } from '$lib/types';
|
|
||||||
import { hashColor, shorthandCode, formatSecondsToHms, formatDate } from '$lib/utils.ts';
|
|
||||||
import TagSelect from './TagSelect.svelte';
|
import TagSelect from './TagSelect.svelte';
|
||||||
|
|
||||||
const ctx = getStreamContext();
|
let { streams } = $props();
|
||||||
let filteredTags = $state([]);
|
let filteredTags = $state([]);
|
||||||
let favoritesOnly = $state(false);
|
let favoritesOnly = $state(false);
|
||||||
let cachedOnly = $state(false);
|
|
||||||
let listOpen = $state();
|
let listOpen = $state();
|
||||||
let displayedStreams = $derived.by(streamsToDisplay);
|
let displayedStreams = $derived.by(streamsToDisplay);
|
||||||
let remainingTags = $derived.by(getRemainingTags);
|
let remainingTags = $derived.by(getRemainingTags);
|
||||||
@@ -23,15 +19,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function streamsToDisplay() {
|
function streamsToDisplay() {
|
||||||
return ctx.streams.filter(
|
return streams.filter(
|
||||||
(stream) =>
|
(stream) =>
|
||||||
!('tags' in stream) || filteredTags.every((tag) => stream.tags.includes(tag))
|
!('tags' in stream) || filteredTags.every((tag) => stream['tags'].includes(tag))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRemainingTags() {
|
function getRemainingTags() {
|
||||||
let tagCounts = displayedStreams.reduce((tags: Record<string, number>, stream) => {
|
let tagCounts = displayedStreams.reduce((tags, stream) => {
|
||||||
stream.tags.forEach((tag) => (tags[tag] ? (tags[tag] += 1) : (tags[tag] = 1)));
|
stream['tags'].forEach((tag) => (tag in tags ? (tags[tag] += 1) : (tags[tag] = 1)));
|
||||||
return tags;
|
return tags;
|
||||||
}, {});
|
}, {});
|
||||||
return Object.entries(tagCounts)
|
return Object.entries(tagCounts)
|
||||||
@@ -39,23 +35,20 @@
|
|||||||
.map((el) => el[0]);
|
.map((el) => el[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDisplayedTagsInList(streamTags: string[], remainingTags: string[]) {
|
function getDisplayedTagsInList(streamTags, remainingTags) {
|
||||||
return streamTags.filter((tag) => remainingTags.includes(tag));
|
return streamTags.filter((tag) => remainingTags.includes(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateFavorites(stream: StreamSummary) {
|
function updateFavorites(stream) {
|
||||||
favoritedStreams.has(stream.id)
|
$favoritedStreams.has(stream['id'])
|
||||||
? favoritedStreams.delete(stream.id)
|
? $favoritedStreams.delete(stream['id'])
|
||||||
: favoritedStreams.add(stream.id);
|
: $favoritedStreams.add(stream['id']);
|
||||||
|
$favoritedStreams = $favoritedStreams; // for reactivity
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="tag-select">
|
<div class="tag-select">
|
||||||
<TagSelect bind:listOpen bind:checked={filteredTags} {remainingTags} />
|
<TagSelect bind:listOpen bind:checked={filteredTags} {remainingTags} />
|
||||||
<button
|
|
||||||
onclick={() => (cachedOnly = !cachedOnly)}
|
|
||||||
class="material-icons filter-download {cachedOnly ? 'select-faves-star' : 'unselect-faves-star'}">file_download</button
|
|
||||||
>
|
|
||||||
<button
|
<button
|
||||||
onclick={() => (favoritesOnly = !favoritesOnly)}
|
onclick={() => (favoritesOnly = !favoritesOnly)}
|
||||||
class="material-icons {favoritesOnly ? '' : 'un'}select-faves-star">star</button
|
class="material-icons {favoritesOnly ? '' : 'un'}select-faves-star">star</button
|
||||||
@@ -63,28 +56,29 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul class="stream-list">
|
<ul class="stream-list">
|
||||||
{#each ctx.streams as stream}
|
{#each streams as stream}
|
||||||
{@const favorited = favoritedStreams.has(stream.id)}
|
{@const favorited = $favoritedStreams.has(stream['id'])}
|
||||||
{@const isCached = streamCache.cached.has(stream.id)}
|
{@const current = $currentStream['id'] === stream['id']}
|
||||||
{@const current = ctx.current?.id === stream.id}
|
|
||||||
<li
|
<li
|
||||||
hidden={!displayedStreams.includes(stream) || (favoritesOnly && !favorited) || (cachedOnly && !isCached)}
|
hidden={!displayedStreams.includes(stream) || (favoritesOnly && !favorited)}
|
||||||
class="stream-item {current ? 'current-stream' : ''}"
|
class="stream-item {current ? 'current-stream' : ''}"
|
||||||
id="stream-{stream.id}"
|
id="stream-{stream['id']}"
|
||||||
>
|
>
|
||||||
<button class="stream-item-button" onclick={() => goto('/streams/' + stream.id)}>
|
<button class="stream-item-button" onclick={() => goto('/streams/' + stream['id'])}>
|
||||||
<span class="stream-item-id">
|
<span class="stream-item-id">
|
||||||
ID:
|
ID:
|
||||||
{shorthandCode(stream.id)}</span
|
{shorthandCode(stream['id'])}</span
|
||||||
>
|
>
|
||||||
|
|
||||||
<span class="stream-item-date">{formatDate(stream.stream_date)}</span>
|
<span class="stream-item-date">{formatDate(stream['stream_date'])}</span>
|
||||||
|
|
||||||
<span class="stream-item-length">{formatSecondsToHms(stream.length_seconds)}</span>
|
<span class="stream-item-length"
|
||||||
|
>{formatSecondsToHms(stream['length_seconds'])}</span
|
||||||
|
>
|
||||||
|
|
||||||
<p class="stream-item-tags" hidden={!remainingTags.length}>
|
<p class="stream-item-tags" hidden={!remainingTags.length}>
|
||||||
Tags: <span hidden={!filteredTags.length}>[...] </span>{getDisplayedTagsInList(
|
Tags: <span hidden={!filteredTags.length}>[...] </span>{getDisplayedTagsInList(
|
||||||
stream.tags,
|
stream['tags'],
|
||||||
remainingTags
|
remainingTags
|
||||||
).join(', ')}
|
).join(', ')}
|
||||||
</p>
|
</p>
|
||||||
@@ -98,19 +92,6 @@
|
|||||||
class="material-icons stream-item-star {favorited ? 'stream-item-star-faved' : ''}"
|
class="material-icons stream-item-star {favorited ? 'stream-item-star-faved' : ''}"
|
||||||
>{favorited ? 'star' : 'star_border'}</button
|
>{favorited ? 'star' : 'star_border'}</button
|
||||||
>
|
>
|
||||||
{#if streamCache.downloading.has(stream.id)}
|
|
||||||
<span class="stream-item-cached">{streamCache.downloading.get(stream.id)}%</span>
|
|
||||||
{:else if isCached}
|
|
||||||
<button
|
|
||||||
onclick={(e) => { e.stopPropagation(); streamCache.remove(stream.id); }}
|
|
||||||
class="material-icons stream-item-cached stream-item-cached-btn">delete</button
|
|
||||||
>
|
|
||||||
{:else}
|
|
||||||
<button
|
|
||||||
onclick={(e) => { e.stopPropagation(); streamCache.download(stream); }}
|
|
||||||
class="material-icons filter-download stream-item-cached stream-item-cached-btn">file_download</button
|
|
||||||
>
|
|
||||||
{/if}
|
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -188,51 +169,24 @@
|
|||||||
.select-faves-star {
|
.select-faves-star {
|
||||||
color: rgba(255, 219, 88, 1);
|
color: rgba(255, 219, 88, 1);
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
transform: translateX(-1px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.unselect-faves-star {
|
.unselect-faves-star {
|
||||||
color: #bbbbbb;
|
color: #bbbbbb;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
transform: translateX(-1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-download {
|
|
||||||
transform: translateY(1px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.stream-item-star {
|
.stream-item-star {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 2px;
|
bottom: 0;
|
||||||
right: 2px;
|
right: 0;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stream-item-star-faved {
|
.stream-item-star-faved {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stream-item-cached {
|
|
||||||
font-size: 18px;
|
|
||||||
position: absolute;
|
|
||||||
bottom: 2px;
|
|
||||||
right: 22px;
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stream-item-cached-btn {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stream-item:hover .stream-item-cached {
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stream-item:hover .stream-item-cached-btn:hover {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stream-item:hover .stream-item-star {
|
.stream-item:hover .stream-item-star {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
@@ -249,15 +203,6 @@
|
|||||||
.stream-item-star {
|
.stream-item-star {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
bottom: 4px;
|
|
||||||
right: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stream-item-cached {
|
|
||||||
opacity: 0.4;
|
|
||||||
font-size: 24px;
|
|
||||||
bottom: 4px;
|
|
||||||
right: 30px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Select from 'svelte-select';
|
import Select from 'svelte-select';
|
||||||
import { tagList } from '$lib/stores.svelte.ts';
|
import { tagList } from '$lib/stores.js';
|
||||||
|
|
||||||
let { checked = $bindable([]), remainingTags = [], listOpen = $bindable() } = $props();
|
let { checked = $bindable([]), remainingTags = [], listOpen = $bindable() } = $props();
|
||||||
let items = $state(tagList.map((x) => ({ value: x, label: x })));
|
let items = $state(tagList.map((x) => ({ value: x, label: x })));
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
{#snippet item({ item })}
|
{#snippet item({ item })}
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<label for={item.value}>
|
<label for={item.value}>
|
||||||
<input type="checkbox" id={item.value} checked={isChecked[item.value]} />
|
<input type="checkbox" id={item.value} bind:checked={isChecked[item.value]} />
|
||||||
{item.label}
|
{item.label}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getStreamContext } from '$lib/streamContext.svelte.ts';
|
import { currentStream } from '$lib/stores.js';
|
||||||
|
|
||||||
const ctx = getStreamContext();
|
currentStream.set({});
|
||||||
ctx.clearCurrent();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="stream-information">
|
<div class="stream-information">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import { getStreamInfo } from '$lib/database.ts';
|
import { getStreamInfo } from '$lib/database.js';
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
import { STREAM_JSON_LOCATION } from '$env/static/private';
|
import { STREAM_JSON_LOCATION } from '$env/static/private';
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { run } from 'svelte/legacy';
|
||||||
|
|
||||||
import StreamPage from './StreamPage.svelte';
|
import StreamPage from './StreamPage.svelte';
|
||||||
import MetadataEditor from './MetadataEditor.svelte';
|
import MetadataEditor from './MetadataEditor.svelte';
|
||||||
import Player from './Player.svelte';
|
import Player from './Player.svelte';
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
import { getStreamContext } from '$lib/streamContext.svelte.ts';
|
import { currentStream, updateCurrentStream } from '$lib/stores.js';
|
||||||
import * as streamCache from '$lib/streamCache.svelte.ts';
|
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
const ctx = getStreamContext();
|
|
||||||
let playerSrc = $state<string | null>(null);
|
|
||||||
|
|
||||||
// reactivity runs on `stream` and `streamCache.cached` here
|
run(() => {
|
||||||
$effect(() => {
|
updateCurrentStream(data.stream);
|
||||||
const stream = data.stream;
|
|
||||||
ctx.setCurrent(stream);
|
|
||||||
playerSrc = null;
|
|
||||||
if (streamCache.cached.has(stream.id)) {
|
|
||||||
streamCache.getUrl(stream.id).then((url) => {
|
|
||||||
playerSrc = url ?? `/media/tracks/${stream.filename}`;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
playerSrc = `/media/tracks/${stream.filename}`;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -33,10 +22,8 @@
|
|||||||
<StreamPage />
|
<StreamPage />
|
||||||
</div>
|
</div>
|
||||||
<div id="player">
|
<div id="player">
|
||||||
{#key playerSrc}
|
{#key $currentStream}
|
||||||
{#if playerSrc}
|
<Player display={true} src="/media/tracks/{$currentStream.filename}" />
|
||||||
<Player display={true} src={playerSrc} />
|
|
||||||
{/if}
|
|
||||||
{/key}
|
{/key}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { tagList } from '$lib/stores.svelte.ts';
|
import { tagList } from '$lib/stores.js';
|
||||||
|
|
||||||
let { original = $bindable() } = $props();
|
let { original = $bindable() } = $props();
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,12 @@
|
|||||||
const bubble = createBubbler();
|
const bubble = createBubbler();
|
||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import { getStreamContext } from '$lib/streamContext.svelte.ts';
|
import {
|
||||||
import type { Track } from '$lib/types';
|
currentSongIndex,
|
||||||
|
currentStream,
|
||||||
const ctx = getStreamContext();
|
getSongAtTime,
|
||||||
|
updateCurrentSong
|
||||||
|
} from '$lib/stores.js';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
src: any;
|
src: any;
|
||||||
@@ -73,23 +75,32 @@
|
|||||||
let seekTrack = $state('');
|
let seekTrack = $state('');
|
||||||
let seeking = $state(false);
|
let seeking = $state(false);
|
||||||
let volumeSeeking = $state(false);
|
let volumeSeeking = $state(false);
|
||||||
let pendingSeekTime = $state<number | null>(null);
|
|
||||||
let songBar = $state();
|
let songBar = $state();
|
||||||
let volumeBar = $state();
|
let volumeBar = $state();
|
||||||
let innerWidth = $state();
|
let innerWidth = $state();
|
||||||
let innerHeight = $state();
|
let innerHeight = $state();
|
||||||
|
let isSafari = $state(false);
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
// work around coreaudio bug
|
||||||
|
// see https://git.webbieweb.org/apt-get/strimserve/issues/1
|
||||||
|
const ua = navigator.userAgent;
|
||||||
|
const isIOS = /iPad|iPhone|iPod/.test(ua);
|
||||||
|
const isDesktopSafari = /Safari/.test(ua) && !/Chrome/.test(ua) && !/Chromium/.test(ua);
|
||||||
|
isSafari = isIOS || isDesktopSafari;
|
||||||
|
|
||||||
// default volume
|
// default volume
|
||||||
const volumeData = localStorage.getItem('volume');
|
const volumeData = localStorage.getItem('volume');
|
||||||
volume = volumeData ? parseFloat(volumeData) : 0.67;
|
volume = volumeData ? parseFloat(volumeData) : 0.67;
|
||||||
setVolume(volume);
|
setVolume(volume);
|
||||||
});
|
|
||||||
|
|
||||||
// update browser metadata on track changes
|
// update browser metadata on track changes
|
||||||
$effect(() => {
|
if ('mediaSession' in navigator) {
|
||||||
if ('mediaSession' in navigator && ctx.songIndex != null && !paused && ctx.current) {
|
currentSongIndex.subscribe((val) => {
|
||||||
setMediaMetadata(ctx.current.tracks[ctx.songIndex]);
|
if (val != null && !paused) {
|
||||||
|
setMediaMetadata($currentStream.tracks[val]);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -108,7 +119,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMediaMetadata(track: Track) {
|
function setMediaMetadata(track) {
|
||||||
navigator.mediaSession.metadata = new MediaMetadata({
|
navigator.mediaSession.metadata = new MediaMetadata({
|
||||||
artist: track[1],
|
artist: track[1],
|
||||||
title: track[2]
|
title: track[2]
|
||||||
@@ -117,8 +128,8 @@
|
|||||||
|
|
||||||
// browsers don't like if you update this while no media is playing
|
// browsers don't like if you update this while no media is playing
|
||||||
function setMediaMetadataOnPlay() {
|
function setMediaMetadataOnPlay() {
|
||||||
if ('mediaSession' in navigator && ctx.current && ctx.songIndex != null) {
|
if ('mediaSession' in navigator) {
|
||||||
setMediaMetadata(ctx.current.tracks[ctx.songIndex]);
|
setMediaMetadata($currentStream.tracks[$currentSongIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,11 +152,6 @@
|
|||||||
audio.currentTime = seek(event, songBar.getBoundingClientRect()) * duration;
|
audio.currentTime = seek(event, songBar.getBoundingClientRect()) * duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSeekVisual(event) {
|
|
||||||
if (!songBar) return;
|
|
||||||
pendingSeekTime = seek(event, songBar.getBoundingClientRect()) * duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
function seekVolume(event) {
|
function seekVolume(event) {
|
||||||
if (!volumeBar) return;
|
if (!volumeBar) return;
|
||||||
volume = seek(event, volumeBar.getBoundingClientRect());
|
volume = seek(event, volumeBar.getBoundingClientRect());
|
||||||
@@ -175,21 +181,18 @@
|
|||||||
}
|
}
|
||||||
let bounds = songBar.getBoundingClientRect();
|
let bounds = songBar.getBoundingClientRect();
|
||||||
let seekValue = ((event.pageX - bounds.left) * duration) / bounds.width;
|
let seekValue = ((event.pageX - bounds.left) * duration) / bounds.width;
|
||||||
if (!ctx.current) return;
|
let trackArray = $currentStream.tracks[getSongAtTime(seekValue)];
|
||||||
let trackArray = ctx.current.tracks[ctx.getSongAtTime(seekValue)];
|
|
||||||
seekTrack = trackArray[1] + ' - ' + trackArray[2];
|
seekTrack = trackArray[1] + ' - ' + trackArray[2];
|
||||||
seekText = formatSeconds(seekValue);
|
seekText = formatSeconds(seekValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function trackMouse(event) {
|
function trackMouse(event) {
|
||||||
if (seeking) updateSeekVisual(event);
|
if (seeking) seekAudio(event);
|
||||||
if (showTooltip && !disableTooltip) seekTooltip(event);
|
if (showTooltip && !disableTooltip) seekTooltip(event);
|
||||||
if (volumeSeeking) seekVolume(event);
|
if (volumeSeeking) seekVolume(event);
|
||||||
}
|
}
|
||||||
run(() => {
|
run(() => {
|
||||||
if (ctx.songIndex != null) {
|
updateCurrentSong(currentTime, $currentSongIndex);
|
||||||
ctx.updateCurrentSong(currentTime, ctx.songIndex);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
run(() => {
|
run(() => {
|
||||||
updateAudioAttributes(audio);
|
updateAudioAttributes(audio);
|
||||||
@@ -217,13 +220,7 @@
|
|||||||
<svelte:window
|
<svelte:window
|
||||||
bind:innerWidth
|
bind:innerWidth
|
||||||
bind:innerHeight
|
bind:innerHeight
|
||||||
onmouseup={() => {
|
onmouseup={() => (seeking = volumeSeeking = false)}
|
||||||
if (seeking && pendingSeekTime != null) {
|
|
||||||
audio.currentTime = pendingSeekTime;
|
|
||||||
pendingSeekTime = null;
|
|
||||||
}
|
|
||||||
seeking = volumeSeeking = false;
|
|
||||||
}}
|
|
||||||
onmousemove={trackMouse}
|
onmousemove={trackMouse}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -242,7 +239,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<progress
|
<progress
|
||||||
bind:this={songBar}
|
bind:this={songBar}
|
||||||
value={seeking && pendingSeekTime != null ? pendingSeekTime : (currentTime || 0)}
|
value={currentTime ? currentTime : 0}
|
||||||
max={duration}
|
max={duration}
|
||||||
onmousedown={() => (seeking = true)}
|
onmousedown={() => (seeking = true)}
|
||||||
onmouseenter={() => (showTooltip = true)}
|
onmouseenter={() => (showTooltip = true)}
|
||||||
@@ -311,8 +308,13 @@
|
|||||||
onended={bubble('ended')}
|
onended={bubble('ended')}
|
||||||
{preload}
|
{preload}
|
||||||
>
|
>
|
||||||
|
{#if isSafari}
|
||||||
|
<source src="{src}.mp3" type="audio/mpeg" />
|
||||||
|
<source {src} type="audio/ogg;codecs=opus" />
|
||||||
|
{:else}
|
||||||
<source {src} type="audio/ogg;codecs=opus" />
|
<source {src} type="audio/ogg;codecs=opus" />
|
||||||
<source src="{src}.mp3" type="audio/mpeg" />
|
<source src="{src}.mp3" type="audio/mpeg" />
|
||||||
|
{/if}
|
||||||
</audio>
|
</audio>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getStreamContext } from '$lib/streamContext.svelte.ts';
|
import { currentStream, currentSongIndex } from '$lib/stores.js';
|
||||||
import { shorthandCode, formatTrackTime, formatDate } from '$lib/utils.ts';
|
import { shorthandCode, formatTrackTime, formatDate } from '$lib/utils.js';
|
||||||
import { jumpToTrack } from './Player.svelte';
|
import { jumpToTrack } from './Player.svelte';
|
||||||
import { Carta } from 'carta-md';
|
import { Carta } from 'carta-md';
|
||||||
import DOMPurify from 'isomorphic-dompurify';
|
import DOMPurify from 'isomorphic-dompurify';
|
||||||
@@ -9,36 +9,31 @@
|
|||||||
sanitizer: DOMPurify.sanitize
|
sanitizer: DOMPurify.sanitize
|
||||||
});
|
});
|
||||||
|
|
||||||
const ctx = getStreamContext();
|
let formattedStreamDate = $derived(formatDate($currentStream.stream_date));
|
||||||
|
|
||||||
let formattedStreamDate = $derived(
|
|
||||||
ctx.current ? formatDate(ctx.current.stream_date) : ''
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{formattedStreamDate} | apt-get's auditorium</title>
|
<title>{formattedStreamDate} | apt-get's auditorium</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
{#if ctx.current}
|
<div class="stream-information">
|
||||||
<div class="stream-information">
|
|
||||||
<div class="stream-information-flexbox">
|
<div class="stream-information-flexbox">
|
||||||
<h3 class="stream-id">ID: {shorthandCode(ctx.current.id)}</h3>
|
<h3 class="stream-id">ID: {shorthandCode($currentStream.id)}</h3>
|
||||||
<h1 class="stream-date">{formattedStreamDate}</h1>
|
<h1 class="stream-date">{formattedStreamDate}</h1>
|
||||||
</div>
|
</div>
|
||||||
<h5 class="stream-tags"><u>Tags</u>: {ctx.current.tags.join(', ')}</h5>
|
<h5 class="stream-tags"><u>Tags</u>: {$currentStream.tags.join(', ')}</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="description-bubble">
|
<div class="description-bubble">
|
||||||
{@html carta.renderSSR(ctx.current.description || 'No description available.')}
|
{@html carta.renderSSR($currentStream.description || 'No description available.')}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="table-container">
|
<div id="table-container">
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr><th>Timestamp</th><th>Artist</th><th>Title</th></tr>
|
<tr><th>Timestamp</th><th>Artist</th><th>Title</th></tr>
|
||||||
{#each ctx.current.tracks as track, i}
|
{#each $currentStream.tracks as track, i}
|
||||||
<tr class:current={i == ctx.songIndex}>
|
<tr class:current={i == $currentSongIndex}>
|
||||||
<td class="timestamp-field"
|
<td class="timestamp-field"
|
||||||
><div class="timestamp-field-flex">
|
><div class="timestamp-field-flex">
|
||||||
{formatTrackTime(track[0])}
|
{formatTrackTime(track[0])}
|
||||||
@@ -56,8 +51,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.stream-information {
|
.stream-information {
|
||||||
|
|||||||
Binary file not shown.
@@ -1,3 +1,4 @@
|
|||||||
|
//import adapter from 'svelte-adapter-bun';
|
||||||
import adapter from 'svelte-adapter-bun';
|
import adapter from 'svelte-adapter-bun';
|
||||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user