@octane-xplat/audio 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/settings.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /** Internal validation shared by the platform leaves. */
2
2
  export function bounded(value: number, min: number, max: number): number {
3
- if (!Number.isFinite(value)) {
4
- throw new RangeError('Audio setting must be finite')
5
- }
6
- return Math.max(min, Math.min(max, value))
3
+ if (!Number.isFinite(value)) {
4
+ throw new RangeError('Audio setting must be finite')
5
+ }
6
+
7
+ return Math.max(min, Math.min(max, value))
7
8
  }
package/src/types.ts CHANGED
@@ -1,102 +1,102 @@
1
1
  /** One playable local path or HTTP(S) source with a stable app-owned identity. */
2
2
  export type Track = {
3
- /** App-owned stable identity — queue operations key on it. */
4
- id: string
5
- /** Local file path or HTTP(S) URL. */
6
- source: string
7
- /** Display title for system controls/lock screen. */
8
- title?: string
9
- /** Display artist for system controls. */
10
- artist?: string
11
- /** Display album for system controls. */
12
- album?: string
3
+ /** App-owned stable identity — queue operations key on it. */
4
+ id: string
5
+ /** Local file path or HTTP(S) URL. */
6
+ source: string
7
+ /** Display title for system controls/lock screen. */
8
+ title?: string
9
+ /** Display artist for system controls. */
10
+ artist?: string
11
+ /** Display album for system controls. */
12
+ album?: string
13
13
  }
14
14
 
15
15
  /** Availability of playback and OS integration on this host. */
16
16
  export type AudioCapabilities = {
17
- /** Any playback path exists on this host. */
18
- supported: boolean
19
- /** Playback can continue when the app is backgrounded/screen-locked. */
20
- backgroundPlayback: boolean
21
- /** Lock screen / control-center / media-key integration is available. */
22
- systemControls: boolean
23
- /** The first play() must be called from a user gesture (web autoplay policy). */
24
- userGestureRequired: boolean
25
- /** The host delivers audio-interruption events (calls, Siri, other apps). */
26
- interruptions: boolean
27
- /** Why supported is false, when known. */
28
- reason?: string
17
+ /** Any playback path exists on this host. */
18
+ supported: boolean
19
+ /** Playback can continue when the app is backgrounded/screen-locked. */
20
+ backgroundPlayback: boolean
21
+ /** Lock screen / control-center / media-key integration is available. */
22
+ systemControls: boolean
23
+ /** The first play() must be called from a user gesture (web autoplay policy). */
24
+ userGestureRequired: boolean
25
+ /** The host delivers audio-interruption events (calls, Siri, other apps). */
26
+ interruptions: boolean
27
+ /** Why supported is false, when known. */
28
+ reason?: string
29
29
  }
30
30
 
31
31
  /** Observable loading, playback, and terminal state. */
32
32
  export type PlaybackState =
33
- | 'idle'
34
- | 'loading'
35
- | 'playing'
36
- | 'paused'
37
- | 'waiting'
38
- | 'ended'
39
- | 'error'
33
+ | 'idle'
34
+ | 'loading'
35
+ | 'playing'
36
+ | 'paused'
37
+ | 'waiting'
38
+ | 'ended'
39
+ | 'error'
40
40
 
41
41
  /** Whether a queue may receive more items. */
42
42
  export interface QueueOptions {
43
- /** Defaults to true for setQueue; updateQueue retains the current value. */
44
- complete?: boolean
43
+ /** Defaults to true for setQueue; updateQueue retains the current value. */
44
+ complete?: boolean
45
45
  }
46
46
 
47
47
  /** Current playback position (seconds) and persistent player settings. */
48
48
  export type AudioSnapshot = {
49
- /** Current observable playback state. */
50
- state: PlaybackState
51
- /** The queue item being played, undefined in 'idle'. */
52
- track?: Track
53
- /** Current position in seconds. */
54
- currentTime: number
55
- /** Track length in seconds, or 0 until known. */
56
- duration: number
57
- /** The failure behind state === 'error'. */
58
- error?: Error
59
- /** Requested speed, 0.5–3; defaults to 1. Pitch is preserved. */
60
- playbackRate: number
61
- /** Remembered gain, 0–1; defaults to 1. Independent of mute. */
62
- volume: number
63
- /** Whether output is muted; defaults to false. */
64
- muted: boolean
65
- /** False while more items may arrive; exhaustion then reports waiting. */
66
- queueComplete: boolean
49
+ /** Current observable playback state. */
50
+ state: PlaybackState
51
+ /** The queue item being played, undefined in 'idle'. */
52
+ track?: Track
53
+ /** Current position in seconds. */
54
+ currentTime: number
55
+ /** Track length in seconds, or 0 until known. */
56
+ duration: number
57
+ /** The failure behind state === 'error'. */
58
+ error?: Error
59
+ /** Requested speed, 0.5–3; defaults to 1. Pitch is preserved. */
60
+ playbackRate: number
61
+ /** Remembered gain, 0–1; defaults to 1. Independent of mute. */
62
+ volume: number
63
+ /** Whether output is muted; defaults to false. */
64
+ muted: boolean
65
+ /** False while more items may arrive; exhaustion then reports waiting. */
66
+ queueComplete: boolean
67
67
  }
68
68
 
69
69
  /** An owned audio queue. Dispose it when its app/service lifetime ends. */
70
70
  export interface AudioPlayer {
71
- /** Inspect host availability before offering OS integrations. */
72
- capabilities(): AudioCapabilities
73
- /** Read current seconds and requested settings. */
74
- snapshot(): AudioSnapshot
75
- /** Observe immediately and on changes; returns an unsubscribe function. */
76
- subscribe(listener: (snapshot: AudioSnapshot) => void): () => void
77
- /** Replace the queue and prepare the clamped zero-based start index, paused. */
78
- setQueue(tracks: readonly Track[], startAt?: number, options?: QueueOptions): Promise<void>
79
- /**
80
- * Replace queue metadata/future items, retaining the current ID+source without
81
- * reloading it. Removing/replacing it selects the first new item paused.
82
- * Appending while waiting resumes only if playback was not explicitly paused.
83
- * Duplicate/empty IDs or sources reject before changing the queue.
84
- */
85
- updateQueue(tracks: readonly Track[], options?: QueueOptions): Promise<void>
86
- /** Begin/resume playback; browser autoplay restrictions may reject. */
87
- play(): Promise<void>
88
- /** Pause, cancelling interruption auto-resume. */
89
- pause(): Promise<void>
90
- /** Seek within the current item in seconds; nonfinite values are ignored. */
91
- seek(seconds: number): Promise<void>
92
- /** Set pitch-preserving speed, clamped to 0.5–3. Nonfinite values reject. */
93
- setPlaybackRate(rate: number): Promise<void>
94
- /** Set remembered gain, clamped to 0–1. Nonfinite values reject. */
95
- setVolume(volume: number): Promise<void>
96
- /** Mute without changing remembered volume. */
97
- setMuted(muted: boolean): Promise<void>
98
- /** Release resources. Repeated disposal is safe. */
99
- dispose(): void
71
+ /** Inspect host availability before offering OS integrations. */
72
+ capabilities(): AudioCapabilities
73
+ /** Read current seconds and requested settings. */
74
+ snapshot(): AudioSnapshot
75
+ /** Observe immediately and on changes; returns an unsubscribe function. */
76
+ subscribe(listener: (snapshot: AudioSnapshot) => void): () => void
77
+ /** Replace the queue and prepare the clamped zero-based start index, paused. */
78
+ setQueue(tracks: readonly Track[], startAt?: number, options?: QueueOptions): Promise<void>
79
+ /**
80
+ * Replace queue metadata/future items, retaining the current ID+source without
81
+ * reloading it. Removing/replacing it selects the first new item paused.
82
+ * Appending while waiting resumes only if playback was not explicitly paused.
83
+ * Duplicate/empty IDs or sources reject before changing the queue.
84
+ */
85
+ updateQueue(tracks: readonly Track[], options?: QueueOptions): Promise<void>
86
+ /** Begin/resume playback; browser autoplay restrictions may reject. */
87
+ play(): Promise<void>
88
+ /** Pause, cancelling interruption auto-resume. */
89
+ pause(): Promise<void>
90
+ /** Seek within the current item in seconds; nonfinite values are ignored. */
91
+ seek(seconds: number): Promise<void>
92
+ /** Set pitch-preserving speed, clamped to 0.5–3. Nonfinite values reject. */
93
+ setPlaybackRate(rate: number): Promise<void>
94
+ /** Set remembered gain, clamped to 0–1. Nonfinite values reject. */
95
+ setVolume(volume: number): Promise<void>
96
+ /** Mute without changing remembered volume. */
97
+ setMuted(muted: boolean): Promise<void>
98
+ /** Release resources. Repeated disposal is safe. */
99
+ dispose(): void
100
100
  }
101
101
 
102
102
  /** Create an independent player on web/iOS/macOS; Android owns one app playback service. */
@@ -4,12 +4,7 @@
4
4
  "audio.android.d.ts",
5
5
  "audio.d.ts",
6
6
  "audio.ios.d.ts",
7
- "audio.macos.d.ts",
8
- "audio.web.d.ts",
9
- "audio.windows.d.ts",
10
7
  "index.d.ts",
11
- "index.macos.d.ts",
12
- "index.web.d.ts",
13
8
  "queue.d.ts",
14
9
  "settings.d.ts",
15
10
  "types.d.ts"
@@ -1,4 +0,0 @@
1
- import type { AudioPlayer } from './types.js';
2
- /** The CLI loads the package's AVFoundation leaf before evaluating the app. */
3
- /** Create an independent player on web/iOS/macOS; Android owns one app playback service. */
4
- export declare const createAudioPlayer: () => AudioPlayer;
@@ -1,3 +0,0 @@
1
- import type { AudioPlayer } from './types.js';
2
- /** Create an independent player on web/iOS/macOS; Android owns one app playback service. */
3
- export declare const createAudioPlayer: () => AudioPlayer;
@@ -1,4 +0,0 @@
1
- import type { AudioPlayer } from './types.js';
2
- /** Keep Windows imports independent of mobile backends; playback is unavailable. */
3
- /** Create an independent player on web/iOS/macOS; Android owns one app playback service. */
4
- export declare const createAudioPlayer: () => AudioPlayer;
@@ -1,2 +0,0 @@
1
- export type * from './types.js';
2
- export { createAudioPlayer } from './audio.macos.js';
@@ -1,2 +0,0 @@
1
- export * from './types.js';
2
- export { createAudioPlayer } from './audio.web.js';