Merge branch 'main' of https://github.com/OllieJT/svelte-podcast
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte-podcast': minor
|
||||
---
|
||||
|
||||
Adds mechanic for managing user preferences
|
||||
@@ -1,5 +1,17 @@
|
||||
# svelte-podcast
|
||||
|
||||
## 0.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 02598d4: fixes exported typings
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 0b12aab: Adds mechanic for managing user preferences
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "svelte-podcast",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.1",
|
||||
"license": "MIT",
|
||||
"author": "Ollie Taylor",
|
||||
"homepage": "https://github.com/OllieJT/svelte-podcast/blob/main/README.md",
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
audio_start_at,
|
||||
} from '$lib/context/audio-internals';
|
||||
import { user_preferences } from '$lib/context/user-preferences';
|
||||
import type { PlayerElement } from '$lib/types/types';
|
||||
import type { AudioPlayerElement } from '$lib/types';
|
||||
import { load_podcast_state } from '$lib/utility/use-state';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
// readonly values
|
||||
let element: PlayerElement;
|
||||
let element: AudioPlayerElement;
|
||||
let current_time = $audio_start_at;
|
||||
let duration = 0;
|
||||
let ended = true;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { PlayerElement } from '$lib/types/types';
|
||||
import type { AudioPlayerElement } from '$lib/types';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
// readonly - stores will update when bindings change
|
||||
export const audio_current_time = writable<number>(0);
|
||||
export const audio_element = writable<PlayerElement>();
|
||||
export const audio_element = writable<AudioPlayerElement>();
|
||||
export const audio_duration = writable<number>(0);
|
||||
export const audio_ended = writable<boolean>(false);
|
||||
export const audio_loading = writable<boolean>(false);
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import type { AudioMetadata } from '$lib/types';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export type AudioMetadata = {
|
||||
title: string;
|
||||
artwork: string;
|
||||
};
|
||||
|
||||
export const audio_metadata = writable<AudioMetadata | null>(null);
|
||||
|
||||
@@ -10,9 +10,10 @@ import {
|
||||
audio_src,
|
||||
audio_start_at,
|
||||
} from '$lib/context/audio-internals';
|
||||
import { audio_metadata, type AudioMetadata } from '$lib/context/audio-metadata';
|
||||
import { audio_metadata } from '$lib/context/audio-metadata';
|
||||
import { episode_progress } from '$lib/context/episode-progress';
|
||||
import { user_preferences } from '$lib/context/user-preferences';
|
||||
import type { AudioLoadData, AudioLoadOptions } from '$lib/types';
|
||||
import { secondsToTimestamp } from '$lib/utility/seconds-to-timestamp';
|
||||
import { info, warn } from '$pkg/log';
|
||||
import clamp from 'just-clamp';
|
||||
@@ -105,13 +106,6 @@ function unmute(type: HandleType = 'set') {
|
||||
}
|
||||
}
|
||||
|
||||
export type AudioLoadData = AudioMetadata & { src: string };
|
||||
|
||||
export type AudioLoadOptions = {
|
||||
autoplay: boolean;
|
||||
start_at?: number;
|
||||
};
|
||||
|
||||
const load = (data: AudioLoadData, opts: AudioLoadOptions) => {
|
||||
episode_progress.stash();
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { browser } from '$app/environment';
|
||||
import { audio, type AudioLoadOptions } from '$lib/context/audio';
|
||||
import { audio } from '$lib/context/audio';
|
||||
import type { AudioLoadOptions, EpisodeProgress } from '$lib/types';
|
||||
import { error, info, warn } from '$lib/utility/package/log';
|
||||
|
||||
export type EpisodeProgress = {
|
||||
current_time: number;
|
||||
};
|
||||
|
||||
const episode_progress_map = new Map<string, EpisodeProgress>();
|
||||
|
||||
function stash_episode() {
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import { browser } from '$app/environment';
|
||||
import type { UserPreferences } from '$lib/types';
|
||||
import { info, warn } from '$lib/utility/package/log';
|
||||
import clamp from 'just-clamp';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export type UserPreferences = {
|
||||
playback_rate: number;
|
||||
volume: number;
|
||||
};
|
||||
|
||||
const default_user_preferences = {
|
||||
playback_rate: 1,
|
||||
volume: 1,
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
export type AudioPlayerElement = HTMLAudioElement | undefined;
|
||||
|
||||
export interface AudioMetadata {
|
||||
title: string;
|
||||
artwork: string;
|
||||
}
|
||||
|
||||
export interface AudioLoadData extends AudioMetadata {
|
||||
src: string;
|
||||
}
|
||||
|
||||
export interface AudioLoadOptions {
|
||||
autoplay: boolean;
|
||||
start_at?: number;
|
||||
}
|
||||
|
||||
export interface EpisodeProgress {
|
||||
current_time: number;
|
||||
}
|
||||
|
||||
export interface UserPreferences {
|
||||
playback_rate: number;
|
||||
volume: number;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export type PlayerElement = HTMLAudioElement | undefined;
|
||||
@@ -6,7 +6,7 @@ const useLogger = {
|
||||
warn: console.warn,
|
||||
};
|
||||
|
||||
export type Logger = keyof typeof useLogger;
|
||||
type Logger = keyof typeof useLogger;
|
||||
|
||||
export function log(type: Logger, ...content: unknown[]) {
|
||||
const logger = useLogger[type];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export function isBoolean(value: any): value is boolean {
|
||||
export function isBoolean(value: unknown): value is boolean {
|
||||
return typeof value === 'boolean';
|
||||
}
|
||||
|
||||
export function isNumber(value: any): value is number {
|
||||
export function isNumber(value: unknown): value is number {
|
||||
return typeof value === 'number' && !isNaN(value);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
audio,
|
||||
episode_progress,
|
||||
save_podcast_state,
|
||||
user_preferences,
|
||||
type AudioLoadData,
|
||||
} from '$lib';
|
||||
import { audio, episode_progress, save_podcast_state, user_preferences } from '$lib';
|
||||
import type { AudioLoadData } from '$lib/types';
|
||||
|
||||
const sources = {
|
||||
syntax: {
|
||||
|
||||
Reference in New Issue
Block a user