@octane-xplat/audio 0.18.0 → 0.19.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/types.ts CHANGED
@@ -1,41 +1,103 @@
1
+ /** One playable local path or HTTP(S) source with a stable app-owned identity. */
1
2
  export type Track = {
3
+ /** App-owned stable identity — queue operations key on it. */
2
4
  id: string
5
+ /** Local file path or HTTP(S) URL. */
3
6
  source: string
7
+ /** Display title for system controls/lock screen. */
4
8
  title?: string
9
+ /** Display artist for system controls. */
5
10
  artist?: string
11
+ /** Display album for system controls. */
6
12
  album?: string
7
13
  }
8
14
 
15
+ /** Availability of playback and OS integration on this host. */
9
16
  export type AudioCapabilities = {
17
+ /** Any playback path exists on this host. */
10
18
  supported: boolean
19
+ /** Playback can continue when the app is backgrounded/screen-locked. */
11
20
  backgroundPlayback: boolean
21
+ /** Lock screen / control-center / media-key integration is available. */
12
22
  systemControls: boolean
23
+ /** The first play() must be called from a user gesture (web autoplay policy). */
13
24
  userGestureRequired: boolean
25
+ /** The host delivers audio-interruption events (calls, Siri, other apps). */
14
26
  interruptions: boolean
27
+ /** Why supported is false, when known. */
15
28
  reason?: string
16
29
  }
17
30
 
18
- export type PlaybackState = 'idle' | 'loading' | 'playing' | 'paused' | 'ended' | 'error'
31
+ /** Observable loading, playback, and terminal state. */
32
+ export type PlaybackState =
33
+ | 'idle'
34
+ | 'loading'
35
+ | 'playing'
36
+ | 'paused'
37
+ | 'waiting'
38
+ | 'ended'
39
+ | 'error'
19
40
 
41
+ /** Whether a queue may receive more items. */
42
+ export interface QueueOptions {
43
+ /** Defaults to true for setQueue; updateQueue retains the current value. */
44
+ complete?: boolean
45
+ }
46
+
47
+ /** Current playback position (seconds) and persistent player settings. */
20
48
  export type AudioSnapshot = {
49
+ /** Current observable playback state. */
21
50
  state: PlaybackState
51
+ /** The queue item being played, undefined in 'idle'. */
22
52
  track?: Track
23
53
  /** Current position in seconds. */
24
54
  currentTime: number
25
55
  /** Track length in seconds, or 0 until known. */
26
56
  duration: number
57
+ /** The failure behind state === 'error'. */
27
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
28
67
  }
29
68
 
69
+ /** An owned audio queue. Dispose it when its app/service lifetime ends. */
30
70
  export interface AudioPlayer {
71
+ /** Inspect host availability before offering OS integrations. */
31
72
  capabilities(): AudioCapabilities
73
+ /** Read current seconds and requested settings. */
32
74
  snapshot(): AudioSnapshot
75
+ /** Observe immediately and on changes; returns an unsubscribe function. */
33
76
  subscribe(listener: (snapshot: AudioSnapshot) => void): () => void
34
- setQueue(tracks: readonly Track[], startAt?: number): Promise<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. */
35
87
  play(): Promise<void>
88
+ /** Pause, cancelling interruption auto-resume. */
36
89
  pause(): Promise<void>
90
+ /** Seek within the current item in seconds; nonfinite values are ignored. */
37
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. */
38
99
  dispose(): void
39
100
  }
40
101
 
102
+ /** Create an independent player on web/iOS/macOS; Android owns one app playback service. */
41
103
  export declare function createAudioPlayer(): AudioPlayer
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": 1,
3
+ "files": [
4
+ "audio.android.d.ts",
5
+ "audio.d.ts",
6
+ "audio.ios.d.ts",
7
+ "audio.macos.d.ts",
8
+ "audio.web.d.ts",
9
+ "audio.windows.d.ts",
10
+ "index.d.ts",
11
+ "index.macos.d.ts",
12
+ "index.web.d.ts",
13
+ "queue.d.ts",
14
+ "settings.d.ts",
15
+ "types.d.ts"
16
+ ]
17
+ }
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export { createAudioPlayer } from './audio.js';
@@ -0,0 +1,2 @@
1
+ export type * from './types.js';
2
+ export { createAudioPlayer } from './audio.macos.js';
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export { createAudioPlayer } from './audio.web.js';
@@ -0,0 +1,3 @@
1
+ import type { Track } from './types.js';
2
+ /** Copy caller data and reject ambiguous identities before changing playback. */
3
+ export declare function copyQueue(tracks: readonly Track[]): Track[];
@@ -0,0 +1,2 @@
1
+ /** Internal validation shared by the platform leaves. */
2
+ export declare function bounded(value: number, min: number, max: number): number;
@@ -0,0 +1,90 @@
1
+ /** One playable local path or HTTP(S) source with a stable app-owned identity. */
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;
13
+ };
14
+ /** Availability of playback and OS integration on this host. */
15
+ export type AudioCapabilities = {
16
+ /** Any playback path exists on this host. */
17
+ supported: boolean;
18
+ /** Playback can continue when the app is backgrounded/screen-locked. */
19
+ backgroundPlayback: boolean;
20
+ /** Lock screen / control-center / media-key integration is available. */
21
+ systemControls: boolean;
22
+ /** The first play() must be called from a user gesture (web autoplay policy). */
23
+ userGestureRequired: boolean;
24
+ /** The host delivers audio-interruption events (calls, Siri, other apps). */
25
+ interruptions: boolean;
26
+ /** Why supported is false, when known. */
27
+ reason?: string;
28
+ };
29
+ /** Observable loading, playback, and terminal state. */
30
+ export type PlaybackState = 'idle' | 'loading' | 'playing' | 'paused' | 'waiting' | 'ended' | 'error';
31
+ /** Whether a queue may receive more items. */
32
+ export interface QueueOptions {
33
+ /** Defaults to true for setQueue; updateQueue retains the current value. */
34
+ complete?: boolean;
35
+ }
36
+ /** Current playback position (seconds) and persistent player settings. */
37
+ export type AudioSnapshot = {
38
+ /** Current observable playback state. */
39
+ state: PlaybackState;
40
+ /** The queue item being played, undefined in 'idle'. */
41
+ track?: Track;
42
+ /** Current position in seconds. */
43
+ currentTime: number;
44
+ /** Track length in seconds, or 0 until known. */
45
+ duration: number;
46
+ /** The failure behind state === 'error'. */
47
+ error?: Error;
48
+ /** Requested speed, 0.5–3; defaults to 1. Pitch is preserved. */
49
+ playbackRate: number;
50
+ /** Remembered gain, 0–1; defaults to 1. Independent of mute. */
51
+ volume: number;
52
+ /** Whether output is muted; defaults to false. */
53
+ muted: boolean;
54
+ /** False while more items may arrive; exhaustion then reports waiting. */
55
+ queueComplete: boolean;
56
+ };
57
+ /** An owned audio queue. Dispose it when its app/service lifetime ends. */
58
+ export interface AudioPlayer {
59
+ /** Inspect host availability before offering OS integrations. */
60
+ capabilities(): AudioCapabilities;
61
+ /** Read current seconds and requested settings. */
62
+ snapshot(): AudioSnapshot;
63
+ /** Observe immediately and on changes; returns an unsubscribe function. */
64
+ subscribe(listener: (snapshot: AudioSnapshot) => void): () => void;
65
+ /** Replace the queue and prepare the clamped zero-based start index, paused. */
66
+ setQueue(tracks: readonly Track[], startAt?: number, options?: QueueOptions): Promise<void>;
67
+ /**
68
+ * Replace queue metadata/future items, retaining the current ID+source without
69
+ * reloading it. Removing/replacing it selects the first new item paused.
70
+ * Appending while waiting resumes only if playback was not explicitly paused.
71
+ * Duplicate/empty IDs or sources reject before changing the queue.
72
+ */
73
+ updateQueue(tracks: readonly Track[], options?: QueueOptions): Promise<void>;
74
+ /** Begin/resume playback; browser autoplay restrictions may reject. */
75
+ play(): Promise<void>;
76
+ /** Pause, cancelling interruption auto-resume. */
77
+ pause(): Promise<void>;
78
+ /** Seek within the current item in seconds; nonfinite values are ignored. */
79
+ seek(seconds: number): Promise<void>;
80
+ /** Set pitch-preserving speed, clamped to 0.5–3. Nonfinite values reject. */
81
+ setPlaybackRate(rate: number): Promise<void>;
82
+ /** Set remembered gain, clamped to 0–1. Nonfinite values reject. */
83
+ setVolume(volume: number): Promise<void>;
84
+ /** Mute without changing remembered volume. */
85
+ setMuted(muted: boolean): Promise<void>;
86
+ /** Release resources. Repeated disposal is safe. */
87
+ dispose(): void;
88
+ }
89
+ /** Create an independent player on web/iOS/macOS; Android owns one app playback service. */
90
+ export declare function createAudioPlayer(): AudioPlayer;
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2026 Alec Larson
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
package/types/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './types.js'
package/types/types.d.ts DELETED
@@ -1,36 +0,0 @@
1
- export type Track = {
2
- id: string;
3
- source: string;
4
- title?: string;
5
- artist?: string;
6
- album?: string;
7
- };
8
- export type AudioCapabilities = {
9
- supported: boolean;
10
- backgroundPlayback: boolean;
11
- systemControls: boolean;
12
- userGestureRequired: boolean;
13
- interruptions: boolean;
14
- reason?: string;
15
- };
16
- export type PlaybackState = 'idle' | 'loading' | 'playing' | 'paused' | 'ended' | 'error';
17
- export type AudioSnapshot = {
18
- state: PlaybackState;
19
- track?: Track;
20
- /** Current position in seconds. */
21
- currentTime: number;
22
- /** Track length in seconds, or 0 until known. */
23
- duration: number;
24
- error?: Error;
25
- };
26
- export interface AudioPlayer {
27
- capabilities(): AudioCapabilities;
28
- snapshot(): AudioSnapshot;
29
- subscribe(listener: (snapshot: AudioSnapshot) => void): () => void;
30
- setQueue(tracks: readonly Track[], startAt?: number): Promise<void>;
31
- play(): Promise<void>;
32
- pause(): Promise<void>;
33
- seek(seconds: number): Promise<void>;
34
- dispose(): void;
35
- }
36
- export declare function createAudioPlayer(): AudioPlayer;