Seek to a specific time in the audio. The `from` parameter
diff --git a/src/routes/api/code/audio-load.js b/src/routes/api/code/audio-load.js
index d48cd37..405a84f 100644
--- a/src/routes/api/code/audio-load.js
+++ b/src/routes/api/code/audio-load.js
@@ -1,17 +1,22 @@
import { audio } from 'svelte-podcast';
-// load a new audio source
-audio.load(
+// load a new audio source into the player
+audio.src.load(
// path to audio file
'/episode-377.mp3',
- // custom metadata
+ // custom metadata defined by you
{
title: 'Supper Club × Rich Harris, Author of Svelte',
+ artwork:
+ 'https://ssl-static.libsyn.com/p/assets/b/3/c/d/b3cdf28da11ad39fe5bbc093207a2619/Syntax_-_499.jpg',
guests: ['Rich Harris'],
hosts: ['Wes Bos', 'Scott Tolinski'],
},
// autoplay
- true,
+ false,
);
+
+// unload the current audio source
+audio.src.unload();
diff --git a/src/routes/api/code/audio-mute.js b/src/routes/api/code/audio-mute.js
index 789fae9..72ba781 100644
--- a/src/routes/api/code/audio-mute.js
+++ b/src/routes/api/code/audio-mute.js
@@ -1,9 +1,10 @@
import { audio } from 'svelte-podcast';
// mute the current audio source
-// do nothing if it's already muted
-audio.mute('set');
+audio.mute(true);
-// mute the current audio if it's unmuted
-// unmute the current audio if it's muted
+// unmute the current audio source
+audio.mute(false);
+
+// invert the mute state of the current audio source
audio.mute('toggle');
diff --git a/src/routes/api/code/audio-pause.js b/src/routes/api/code/audio-pause.js
deleted file mode 100644
index bfa3dd8..0000000
--- a/src/routes/api/code/audio-pause.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import { audio } from 'svelte-podcast';
-
-// pause the current audio source
-// do nothing if it's already paused
-audio.pause('set');
-
-// pause the current audio if it's playing
-// play the current audio if it's paused
-audio.pause('toggle');
diff --git a/src/routes/api/code/audio-play.js b/src/routes/api/code/audio-play.js
index 0fd33c2..a2f5cf2 100644
--- a/src/routes/api/code/audio-play.js
+++ b/src/routes/api/code/audio-play.js
@@ -1,9 +1,10 @@
import { audio } from 'svelte-podcast';
// play the current audio source
-// do nothing if it's already playing
-audio.play('set');
+audio.play(true);
-// play the current audio if it's paused
-// pause the current audio if it's playing
+// pause the current audio source
+audio.play(false);
+
+// invert the play state of the current audio source
audio.play('toggle');
diff --git a/src/routes/api/code/audio-seek.js b/src/routes/api/code/audio-seek.js
index 17a2e2a..57eb4a2 100644
--- a/src/routes/api/code/audio-seek.js
+++ b/src/routes/api/code/audio-seek.js
@@ -1,7 +1,7 @@
import { audio } from 'svelte-podcast';
// go to 200 seconds from the start
-audio.seek(200);
+audio.seek_to(200);
// go to 200 seconds before the end
-audio.seek(200, 'from-end');
+audio.seek_to(200, 'from-end');
diff --git a/src/routes/api/code/audio-skip.js b/src/routes/api/code/audio-skip.js
index 0b89e7e..2056151 100644
--- a/src/routes/api/code/audio-skip.js
+++ b/src/routes/api/code/audio-skip.js
@@ -1,7 +1,7 @@
import { audio } from 'svelte-podcast';
// skip forward 30 seconds from the current position
-audio.skip(30);
+audio.skip_by(30);
// skip backward 30 seconds from the current position
-audio.skip(30, 'backward');
+audio.skip_by(30, 'backward');
diff --git a/src/routes/api/code/audio-unload.js b/src/routes/api/code/audio-unload.js
deleted file mode 100644
index af801f9..0000000
--- a/src/routes/api/code/audio-unload.js
+++ /dev/null
@@ -1,4 +0,0 @@
-import { audio } from 'svelte-podcast';
-
-// unload the current audio source
-audio.unload();
diff --git a/src/routes/api/code/audio-unmute.js b/src/routes/api/code/audio-unmute.js
deleted file mode 100644
index 51e1789..0000000
--- a/src/routes/api/code/audio-unmute.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import { audio } from 'svelte-podcast';
-
-// unmute the current audio source
-// do nothing if it's already unmuted
-audio.unmute('set');
-
-// unmute the current audio if it's muted
-// mute the current audio if it's unmuted
-audio.unmute('toggle');
diff --git a/src/routes/api/code/index.js b/src/routes/api/code/index.js
index 716e32a..4fee67e 100644
--- a/src/routes/api/code/index.js
+++ b/src/routes/api/code/index.js
@@ -1,13 +1,10 @@
import { format_code } from '../../../layout/helper';
-import { default as audio_load_src } from './audio-load.js?raw';
-import { default as audio_mute_src } from './audio-mute.js?raw';
-import { default as audio_pause_src } from './audio-pause.js?raw';
-import { default as audio_play_src } from './audio-play.js?raw';
-import { default as audio_seek_src } from './audio-seek.js?raw';
-import { default as audio_skip_src } from './audio-skip.js?raw';
+import { default as audio_load_src } from './audio-load?raw';
+import { default as audio_mute_src } from './audio-mute?raw';
+import { default as audio_play_src } from './audio-play?raw';
+import { default as audio_seek_src } from './audio-seek?raw';
+import { default as audio_skip_src } from './audio-skip?raw';
import { default as audio_subscribe_src } from './audio-subscribe.svelte?raw';
-import { default as audio_unload_src } from './audio-unload.js?raw';
-import { default as audio_unmute_src } from './audio-unmute.js?raw';
import { default as load_audio_after_click_src } from './load-audio-after-click.svelte?raw';
import { default as load_audio_after_mount_src } from './load-audio-after-mount.svelte?raw';
import { default as seconds_to_timestamp_src } from './seconds-to-timestamp?raw';
@@ -25,12 +22,9 @@ export const load_audio_after_mount = format_code(load_audio_after_mount_src);
export const seconds_to_timestamp = format_code(seconds_to_timestamp_src);
export const audio_load = format_code(audio_load_src);
export const audio_play = format_code(audio_play_src);
-export const audio_unload = format_code(audio_unload_src);
-export const audio_pause = format_code(audio_pause_src);
export const audio_skip = format_code(audio_skip_src);
export const audio_seek = format_code(audio_seek_src);
export const audio_mute = format_code(audio_mute_src);
-export const audio_unmute = format_code(audio_unmute_src);
export const user_preferences_clear = format_code(user_preferences_clear_src);
export const user_preferences_set_playback_rate = format_code(
user_preferences_set_playback_rate_src,
diff --git a/src/routes/api/code/load-audio-after-click.svelte b/src/routes/api/code/load-audio-after-click.svelte
index 1fa0fde..60635f6 100644
--- a/src/routes/api/code/load-audio-after-click.svelte
+++ b/src/routes/api/code/load-audio-after-click.svelte
@@ -5,12 +5,14 @@
-
+
diff --git a/src/routes/api/code/load-audio-after-mount.svelte b/src/routes/api/code/load-audio-after-mount.svelte
index 28230f3..349c495 100644
--- a/src/routes/api/code/load-audio-after-mount.svelte
+++ b/src/routes/api/code/load-audio-after-mount.svelte
@@ -4,8 +4,10 @@
onMount(() => {
// load the episode on mount without any metadata
- audio.load('/episode-audio.mp3', {
- /* optional metadata */
+ audio.src.load('/episode-audio.mp3', {
+ /* your metadata */
+ title: 'Episode Title',
+ artwork: '/artwork.png',
});
});
diff --git a/src/routes/api/code/seconds-to-timestamp.js b/src/routes/api/code/seconds-to-timestamp.js
index 68957e7..4ecdae4 100644
--- a/src/routes/api/code/seconds-to-timestamp.js
+++ b/src/routes/api/code/seconds-to-timestamp.js
@@ -1,8 +1,10 @@
-import { seconds_to_timestamp } from 'svelte-podcast/utility';
+import { format_seconds } from 'svelte-podcast/utility/format-seconds';
// Example
-seconds_to_timestamp(5173); // 01:26:13
+format_seconds.to_timestamp(5173); // '01:26:13';
-// force hours
-seconds_to_timestamp(2700, true); // 00:45:00
-seconds_to_timestamp(2700, false); // 45:00 (default)
+// force hours to be displayed
+format_seconds.to_timestamp(2700, true); // '00:45:00';
+
+// only display hours if there are any
+format_seconds.to_timestamp(2700, false); // '45:00';
diff --git a/src/routes/api/code/user_preferences-clear.js b/src/routes/api/code/user_preferences-clear.js
index b640bba..231a910 100644
--- a/src/routes/api/code/user_preferences-clear.js
+++ b/src/routes/api/code/user_preferences-clear.js
@@ -1,4 +1,4 @@
-import { user_preferences } from '../../../lib/user';
+import { user_preferences } from 'svelte-podcast';
// Clears all user preferences
user_preferences.clear();
diff --git a/src/routes/api/code/user_preferences-set_playback_rate.js b/src/routes/api/code/user_preferences-set_playback_rate.js
index 6b913a7..f64784c 100644
--- a/src/routes/api/code/user_preferences-set_playback_rate.js
+++ b/src/routes/api/code/user_preferences-set_playback_rate.js
@@ -1,4 +1,4 @@
-import { user_preferences } from '../../../lib/user';
+import { user_preferences } from 'svelte-podcast';
// Sets the playback speed to 150%
user_preferences.set_playback_rate(1.5);
diff --git a/src/routes/api/code/user_preferences-set_volume.js b/src/routes/api/code/user_preferences-set_volume.js
index f137499..b799cac 100644
--- a/src/routes/api/code/user_preferences-set_volume.js
+++ b/src/routes/api/code/user_preferences-set_volume.js
@@ -1,4 +1,4 @@
-import { user_preferences } from '../../../lib/user';
+import { user_preferences } from 'svelte-podcast';
// Sets the volume to 75%
user_preferences.set_volume(0.75);
diff --git a/src/routes/components/code/audio-progress.svelte b/src/routes/components/code/audio-progress.svelte
index f29de20..6db8b9d 100644
--- a/src/routes/components/code/audio-progress.svelte
+++ b/src/routes/components/code/audio-progress.svelte
@@ -1,5 +1,5 @@
diff --git a/src/routes/setup/+page.svelte b/src/routes/setup/+page.svelte
index af58fe4..67d762c 100644
--- a/src/routes/setup/+page.svelte
+++ b/src/routes/setup/+page.svelte
@@ -70,7 +70,7 @@
Along side your audio source, you can optionally define arbitrary
metadata for you to use in your player, and determine if the episode
should autoplay once loaded. Learn more in the api docsapi docs
diff --git a/src/routes/setup/code/load-audio-advanced.js b/src/routes/setup/code/load-audio-advanced.js
index f3ffd95..8bb67c5 100644
--- a/src/routes/setup/code/load-audio-advanced.js
+++ b/src/routes/setup/code/load-audio-advanced.js
@@ -1,14 +1,16 @@
import { audio } from 'svelte-podcast';
-audio.load('/episode-audio.mp3');
+audio.src.load(
+ // Audio file
+ '/episode-audio.mp3',
-audio.load(
- 'https://media.transistor.fm/27a058c9/27b595e2.mp3',
+ // Your custom metadata
{
- title: 'SvelteKit-superforms with Andreas Söderlund',
- artwork:
- 'https://images.transistor.fm/file/transistor/images/show/12899/medium_1597678946-artwork.jpg',
- guest_name: 'Andreas Söderlund',
+ title: 'A deep dive into Svelte Podcast',
+ artwork: '/artwork.png',
+ guest_name: 'OllieJT',
},
+
+ // Autoplay once loaded
false,
);
diff --git a/src/routes/setup/code/load-audio-local.js b/src/routes/setup/code/load-audio-local.js
index 3a15bae..e3b77fb 100644
--- a/src/routes/setup/code/load-audio-local.js
+++ b/src/routes/setup/code/load-audio-local.js
@@ -1,3 +1,6 @@
import { audio } from 'svelte-podcast';
-audio.load('/episode-audio.mp3');
+audio.src.load('/episode-audio.mp3', {
+ title: 'Episode Title',
+ artwork: '/artwork.png',
+});
diff --git a/src/routes/setup/code/load-audio-remote.js b/src/routes/setup/code/load-audio-remote.js
index 1de7c79..4ae9124 100644
--- a/src/routes/setup/code/load-audio-remote.js
+++ b/src/routes/setup/code/load-audio-remote.js
@@ -1,3 +1,6 @@
import { audio } from 'svelte-podcast';
-audio.load('https://media.transistor.fm/27a058c9/27b595e2.mp3');
+audio.src.load('https://media.transistor.fm/27a058c9/27b595e2.mp3', {
+ title: 'Episode Title',
+ artwork: '/artwork.png',
+});
diff --git a/src/routes/setup/code/override-episode-state.ts b/src/routes/setup/code/override-episode-state.ts
index 0da531e..b0a11b9 100644
--- a/src/routes/setup/code/override-episode-state.ts
+++ b/src/routes/setup/code/override-episode-state.ts
@@ -1,10 +1,9 @@
// include this in your /src/app.d.ts file
declare module 'svelte-podcast' {
- interface EpisodeDetails {
+ interface AudioMetadata {
title: string;
- artwork: string;
- guest_name: string;
+ artwork: string | null;
}
}
diff --git a/static/podstack.png b/static/podstack.png
new file mode 100644
index 0000000..0e14d8b
Binary files /dev/null and b/static/podstack.png differ