2023-02-22 10:24:39 +00:00
|
|
|
|
<script lang="ts">
|
2023-02-25 14:16:19 +00:00
|
|
|
|
import { podcast_preferences, podcast_progress, save_podcast_state } from '$lib';
|
|
|
|
|
|
import { episode_audio, episode_progress } from '$lib/audio';
|
2023-02-21 23:54:18 +00:00
|
|
|
|
|
2023-02-22 10:24:39 +00:00
|
|
|
|
const sources = {
|
2023-02-24 15:38:33 +00:00
|
|
|
|
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`,
|
|
|
|
|
|
},
|
2023-02-25 14:16:19 +00:00
|
|
|
|
} as const;
|
2023-02-23 12:09:08 +00:00
|
|
|
|
|
|
|
|
|
|
let current_time = 0;
|
2023-02-25 14:16:19 +00:00
|
|
|
|
$: current_time = $episode_progress.current_time;
|
2023-02-21 23:54:18 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2023-02-25 01:04:08 +00:00
|
|
|
|
<pre>{JSON.stringify(
|
|
|
|
|
|
{
|
2023-02-25 14:16:19 +00:00
|
|
|
|
$episode_audio,
|
|
|
|
|
|
$episode_progress,
|
|
|
|
|
|
$podcast_preferences,
|
2023-02-25 01:04:08 +00:00
|
|
|
|
},
|
|
|
|
|
|
null,
|
|
|
|
|
|
3,
|
|
|
|
|
|
)}</pre>
|
2023-02-22 16:40:02 +00:00
|
|
|
|
|
2023-02-21 23:54:18 +00:00
|
|
|
|
<h1>Demo</h1>
|
2023-02-23 12:09:08 +00:00
|
|
|
|
<a href="/another-page">Another Page</a>
|
2023-02-25 14:16:19 +00:00
|
|
|
|
<button type="button" on:click={podcast_progress.save}>Save progress</button>
|
2023-02-25 01:04:08 +00:00
|
|
|
|
<button type="button" on:click={podcast_preferences.save}>Save preferences</button>
|
2023-02-24 20:04:01 +00:00
|
|
|
|
<button type="button" on:click={save_podcast_state}>Save state (all)</button>
|
2023-02-22 16:40:02 +00:00
|
|
|
|
|
|
|
|
|
|
<h5>Load Audio</h5>
|
2023-02-25 14:16:19 +00:00
|
|
|
|
<button type="button" on:click={() => episode_audio.load(sources['syntax'].src, sources['knomii'])}
|
2023-02-25 01:04:08 +00:00
|
|
|
|
>Syntax</button
|
2023-02-24 14:01:43 +00:00
|
|
|
|
>
|
2023-02-25 14:16:19 +00:00
|
|
|
|
<button type="button" on:click={() => episode_audio.load(sources['knomii'].src, sources['knomii'])}
|
2023-02-24 14:01:43 +00:00
|
|
|
|
>Knomii</button
|
|
|
|
|
|
>
|
2023-02-25 14:16:19 +00:00
|
|
|
|
<button type="button" on:click={() => episode_audio.unload()}>None</button>
|
2023-02-22 00:30:12 +00:00
|
|
|
|
|
2023-02-22 16:40:02 +00:00
|
|
|
|
<h5>Custom audio controls</h5>
|
2023-02-21 23:54:18 +00:00
|
|
|
|
|
2023-02-22 23:41:29 +00:00
|
|
|
|
<h6>Play / Pause Actions</h6>
|
|
|
|
|
|
|
2023-02-25 14:16:19 +00:00
|
|
|
|
<button type="button" on:click={() => episode_audio.play()}>Play</button>
|
|
|
|
|
|
<button type="button" on:click={() => episode_audio.pause()}>Pause</button>
|
|
|
|
|
|
<button type="button" on:click={() => episode_audio.pause('toggle')}>Toggle</button>
|
2023-02-22 23:41:29 +00:00
|
|
|
|
|
2023-02-22 16:40:02 +00:00
|
|
|
|
<h6>Audio Actions</h6>
|
2023-02-21 23:54:18 +00:00
|
|
|
|
|
2023-02-25 14:16:19 +00:00
|
|
|
|
<button type="button" on:click={() => episode_audio.mute()}>Mute</button>
|
|
|
|
|
|
<button type="button" on:click={() => episode_audio.unmute()}>Unmute</button>
|
|
|
|
|
|
<button type="button" on:click={() => episode_audio.mute('toggle')}>Toggle</button>
|
2023-02-21 23:54:18 +00:00
|
|
|
|
|
2023-02-22 16:40:02 +00:00
|
|
|
|
<h6>Seeking</h6>
|
2023-02-21 23:54:18 +00:00
|
|
|
|
|
2023-02-23 12:09:08 +00:00
|
|
|
|
<input
|
|
|
|
|
|
type="range"
|
|
|
|
|
|
min={0}
|
2023-02-25 14:16:19 +00:00
|
|
|
|
max={$episode_audio?.duration}
|
2023-02-23 12:09:08 +00:00
|
|
|
|
style="width:100%"
|
|
|
|
|
|
bind:value={current_time}
|
2023-02-25 14:16:19 +00:00
|
|
|
|
on:change={(e) => episode_audio.seek(parseInt(e.currentTarget.value))}
|
2023-02-23 12:09:08 +00:00
|
|
|
|
/>
|
|
|
|
|
|
|
2023-02-25 14:16:19 +00:00
|
|
|
|
<button type="button" on:click={() => episode_audio.seek(30)}>Go to 30s from start </button>
|
|
|
|
|
|
<button type="button" on:click={() => episode_audio.seek(30, 'from-end')}>Go to 30s from end</button
|
2023-02-25 01:04:08 +00:00
|
|
|
|
>
|
2023-02-25 14:16:19 +00:00
|
|
|
|
<button type="button" on:click={() => episode_audio.skip(10, 'forward')}>Skip 10s</button>
|
|
|
|
|
|
<button type="button" on:click={() => episode_audio.skip(10, 'backward')}>Rewind 10s</button>
|
2023-02-21 23:54:18 +00:00
|
|
|
|
|
2023-02-22 16:40:02 +00:00
|
|
|
|
<h6>Playback Rate</h6>
|
2023-02-21 23:54:18 +00:00
|
|
|
|
|
2023-02-22 16:40:02 +00:00
|
|
|
|
{#each [0.5, 1, 2, 3] as rate}
|
2023-02-25 01:14:35 +00:00
|
|
|
|
<button type="button" on:click={() => podcast_preferences.edit({ playback_rate: rate })}>
|
|
|
|
|
|
{rate}x
|
|
|
|
|
|
</button>
|
2023-02-22 16:40:02 +00:00
|
|
|
|
{/each}
|