Add metadata store
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export type AudioMetadata = {
|
||||
title: string;
|
||||
artwork: string;
|
||||
};
|
||||
|
||||
export const audio_metadata = writable<AudioMetadata | null>(null);
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
audio_start_at,
|
||||
audio_volume,
|
||||
} from '$lib/context/audio-internals';
|
||||
import { audio_metadata, type AudioMetadata } from '$lib/context/audio-metadata';
|
||||
import { secondsToTimestamp } from '$lib/utility/seconds-to-timestamp';
|
||||
import { info, warn } from '$pkg/log';
|
||||
import clamp from 'just-clamp';
|
||||
@@ -30,6 +31,7 @@ const audio_state = derived(
|
||||
audio_playback_rate,
|
||||
audio_src,
|
||||
audio_volume,
|
||||
audio_metadata,
|
||||
],
|
||||
([
|
||||
$current_time,
|
||||
@@ -43,6 +45,7 @@ const audio_state = derived(
|
||||
$playback_rate,
|
||||
$src,
|
||||
$volume,
|
||||
$metadata,
|
||||
]) => {
|
||||
return {
|
||||
current_time: $current_time,
|
||||
@@ -56,6 +59,7 @@ const audio_state = derived(
|
||||
playback_rate: $playback_rate,
|
||||
src: $src,
|
||||
volume: $volume,
|
||||
metadata: $metadata,
|
||||
timestamp: secondsToTimestamp($current_time),
|
||||
};
|
||||
},
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
export { default as AudioLoader } from '$lib/components/audio-loader.svelte';
|
||||
export { audio } from '$lib/context/audio';
|
||||
export { audio, type AudioLoadData, type AudioLoadOptions } from '$lib/context/audio';
|
||||
|
||||
+12
-4
@@ -1,10 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { audio } from '$lib';
|
||||
import { audio, type AudioLoadData } from '$lib';
|
||||
|
||||
const sources = {
|
||||
syntax: '/example-syntax.mp3',
|
||||
knomii: '/example-knomii.mp3',
|
||||
} as const;
|
||||
syntax: {
|
||||
src: `/example-syntax.mp3`,
|
||||
title: `Supper Club × Rich Harris, Author of Svelte`,
|
||||
artwork: `https://ssl-static.libsyn.com/p/assets/b/3/c/d/b3cdf28da11ad39fe5bbc093207a2619/Syntax_-_499.jpg`,
|
||||
},
|
||||
knomii: {
|
||||
src: `/example-knomii.mp3`,
|
||||
title: `Empowerment starts with letting go of control`,
|
||||
artwork: `https://ssl-static.libsyn.com/p/assets/f/a/8/d/fa8d56d5226884335f2e77a3093c12a1/ep-6.png`,
|
||||
},
|
||||
} satisfies Record<string, AudioLoadData>;
|
||||
|
||||
let current_time = 0;
|
||||
$: current_time = $audio.current_time;
|
||||
|
||||
Reference in New Issue
Block a user