Add metadata store

This commit is contained in:
Ollie Taylor
2023-02-24 15:38:33 +00:00
parent b929000d0a
commit c4a1927b7f
4 changed files with 25 additions and 5 deletions
+8
View File
@@ -0,0 +1,8 @@
import { writable } from 'svelte/store';
export type AudioMetadata = {
title: string;
artwork: string;
};
export const audio_metadata = writable<AudioMetadata | null>(null);
+4
View File
@@ -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),
};
},