@octane-xplat/audio 0.18.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 -66
- package/package.json +103 -98
- package/platforms/android/audio.aar +0 -0
- package/platforms/android/java/com/xplat/audio/AudioBridge.java +16 -8
- package/platforms/android/java/com/xplat/audio/AudioPlaybackService.java +63 -10
- package/platforms/macos/include/XplatAudioPlayer.h +3 -0
- package/platforms/macos/src/XplatAudioPlayer.m +27 -1
- package/src/audio.android.ts +193 -136
- package/src/audio.ios.ts +495 -377
- package/src/audio.macos.ts +372 -267
- package/src/audio.ts +8 -7
- package/src/audio.web.ts +306 -179
- package/src/audio.windows.ts +7 -0
- package/src/queue.ts +15 -0
- package/src/settings.ts +8 -0
- package/src/types.ts +89 -27
- package/types/generated/.tsrx-typegen-manifest.json +12 -0
- package/types/generated/audio.android.d.ts +3 -0
- package/types/generated/audio.d.ts +3 -0
- package/types/generated/audio.ios.d.ts +3 -0
- package/types/generated/index.d.ts +2 -0
- package/types/generated/queue.d.ts +3 -0
- package/types/generated/settings.d.ts +2 -0
- package/types/generated/types.d.ts +90 -0
- package/LICENSE +0 -21
- package/types/index.d.ts +0 -1
- package/types/types.d.ts +0 -36
|
@@ -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;
|