@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/README.md +2 -114
- package/package.json +7 -6
- package/src/audio.android.ts +190 -180
- package/src/audio.ios.ts +492 -472
- package/src/audio.macos.ts +369 -354
- package/src/audio.ts +7 -7
- package/src/audio.web.ts +303 -290
- package/src/audio.windows.ts +1 -1
- package/src/queue.ts +10 -8
- package/src/settings.ts +5 -4
- package/src/types.ts +78 -78
- package/types/generated/.tsrx-typegen-manifest.json +0 -5
- package/types/generated/audio.macos.d.ts +0 -4
- package/types/generated/audio.web.d.ts +0 -3
- package/types/generated/audio.windows.d.ts +0 -4
- package/types/generated/index.macos.d.ts +0 -2
- package/types/generated/index.web.d.ts +0 -2
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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. */
|
|
@@ -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,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;
|