Add navigating example to demo

This commit is contained in:
Ollie Taylor
2023-02-23 12:09:08 +00:00
parent 69346b6c19
commit 3e7ab99121
3 changed files with 38 additions and 9 deletions
+7
View File
@@ -0,0 +1,7 @@
<script lang="ts">
import { AudioManager } from '$lib/components/audio';
</script>
<AudioManager />
<slot />
+14 -9
View File
@@ -1,23 +1,19 @@
<script lang="ts"> <script lang="ts">
import { audio, AudioManager } from '$lib/components/audio'; import { audio } from '$lib/components/audio';
const sources = { const sources = {
syntax: '/example-syntax.mp3', syntax: '/example-syntax.mp3',
knomii: '/example-knomii.mp3', knomii: '/example-knomii.mp3',
} as const; } as const;
let current_time = 0;
$: current_time = $audio.current_time;
</script> </script>
<pre>{JSON.stringify($audio, null, 3)}</pre> <pre>{JSON.stringify($audio, null, 3)}</pre>
<h1>Demo</h1> <h1>Demo</h1>
<a href="/another-page">Another Page</a>
<AudioManager on:progress={(e) => console.log(e.detail)} />
<!-- <progress
style="width: 960px; max-width:100%"
data-paused={$_paused ? 'true' : 'false'}
max={$_duration}
value={$_currentTime}
/> -->
<h5>Load Audio</h5> <h5>Load Audio</h5>
<button type="button" on:click={() => audio.load(sources['syntax'])}>Syntax</button> <button type="button" on:click={() => audio.load(sources['syntax'])}>Syntax</button>
@@ -40,6 +36,15 @@
<h6>Seeking</h6> <h6>Seeking</h6>
<input
type="range"
min={0}
max={$audio.duration}
style="width:100%"
bind:value={current_time}
on:change={(e) => audio.seek(parseInt(e.currentTarget.value))}
/>
<button type="button" on:click={() => audio.seek(30)}>Go to 30s from start </button> <button type="button" on:click={() => audio.seek(30)}>Go to 30s from start </button>
<button type="button" on:click={() => audio.seek(30, 'from-end')}>Go to 30s from end</button> <button type="button" on:click={() => audio.seek(30, 'from-end')}>Go to 30s from end</button>
<button type="button" on:click={() => audio.skip(10, 'forward')}>Skip 10s</button> <button type="button" on:click={() => audio.skip(10, 'forward')}>Skip 10s</button>
+17
View File
@@ -0,0 +1,17 @@
<script lang="ts">
import { audio } from '$lib/components/audio';
const sources = {
syntax: '/example-syntax.mp3',
knomii: '/example-knomii.mp3',
} as const;
let current_time = 0;
$: current_time = $audio.current_time;
</script>
<h1>Demo</h1>
<a href="/">Demo</a>
<pre>{JSON.stringify($audio, null, 3)}</pre>