@octane-xplat/audio 0.9.0 → 0.10.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 +14 -6
- package/dist/native/index2.js +1 -1
- package/dist/native/octane-client-build.json +1 -1
- package/dist/web/index2.js +3 -1
- package/dist/web/octane-client-build.json +1 -1
- package/package.json +2 -2
- package/src/audio.android.ts +2 -1
- package/src/audio.ios.ts +6 -1
- package/src/audio.web.ts +3 -0
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# `@octane-xplat/audio`
|
|
2
2
|
|
|
3
|
+
```sh
|
|
4
|
+
pnpm add @octane-xplat/audio
|
|
5
|
+
```
|
|
6
|
+
|
|
3
7
|
Long-form audio playback for Octane xplat apps — a queue player, not a
|
|
4
8
|
sound-effect bank. iOS drives `AVPlayer`/`AVAudioSession` (interruption
|
|
5
9
|
handling included) and Android `MediaPlayer`, both directly on
|
|
6
10
|
`@nativescript/core` with no plugin dependency; web drives an
|
|
7
11
|
`HTMLAudioElement` plus the Media Session API for system controls.
|
|
8
12
|
|
|
9
|
-
```sh
|
|
10
|
-
pnpm add @octane-xplat/audio
|
|
11
|
-
```
|
|
12
|
-
|
|
13
13
|
```ts
|
|
14
14
|
import { createAudioPlayer } from '@octane-xplat/audio'
|
|
15
15
|
|
|
@@ -29,9 +29,17 @@ promising behavior like lock-screen controls. The native entry requires
|
|
|
29
29
|
iOS or Android — other targets get the web implementation or a thrown
|
|
30
30
|
error, never a silent no-op.
|
|
31
31
|
|
|
32
|
+
```ts
|
|
33
|
+
// Continue with the player created above.
|
|
34
|
+
const capabilities = player.capabilities()
|
|
35
|
+
console.log(capabilities.backgroundPlayback, capabilities.systemControls)
|
|
36
|
+
off()
|
|
37
|
+
player.dispose()
|
|
38
|
+
```
|
|
39
|
+
|
|
32
40
|
For short UI sounds use [`@octane-xplat/sounds`](../sounds/README.md).
|
|
33
41
|
|
|
34
|
-
Guide: [Media services](../../docs/media-services.md); per-target
|
|
35
|
-
availability: [platform notes](../../docs/platform-notes.md). Exercised by
|
|
42
|
+
Guide: [Media services](../../docs/platform/media-services.md); per-target
|
|
43
|
+
availability: [platform notes](../../docs/notes/platform-notes.md). Exercised by
|
|
36
44
|
the harness `MediaServices` screen
|
|
37
45
|
([`packages/app/src/MediaServices.tsrx`](../app/src/MediaServices.tsrx)).
|
package/dist/native/index2.js
CHANGED
|
@@ -198,7 +198,7 @@ var createAudioPlayer = () => {
|
|
|
198
198
|
if (timer) clearInterval(timer);
|
|
199
199
|
timer = void 0;
|
|
200
200
|
if (nowPlaying) nowPlaying.nowPlayingInfo = null;
|
|
201
|
-
session.setActiveWithOptionsError(false, notifyOthersOnDeactivation,
|
|
201
|
+
session.setActiveWithOptionsError(false, notifyOthersOnDeactivation, null);
|
|
202
202
|
listeners.clear();
|
|
203
203
|
queue = [];
|
|
204
204
|
index = -1;
|
package/dist/web/index2.js
CHANGED
|
@@ -73,12 +73,14 @@ var createAudioPlayer = () => {
|
|
|
73
73
|
"timeupdate",
|
|
74
74
|
"durationchange",
|
|
75
75
|
"play",
|
|
76
|
+
"playing",
|
|
76
77
|
"pause",
|
|
77
78
|
"ended",
|
|
78
79
|
"waiting",
|
|
79
80
|
"error"
|
|
80
81
|
]) audio.addEventListener(event, () => {
|
|
81
|
-
if (event === "play") state = "
|
|
82
|
+
if (event === "play") state = "loading";
|
|
83
|
+
else if (event === "playing") state = "playing";
|
|
82
84
|
else if (event === "pause" && state !== "ended") state = "paused";
|
|
83
85
|
else if (event === "ended") {
|
|
84
86
|
state = "ended";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/audio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Long-form audio playback for Octane xplat",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"android",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@nativescript/core": "9.1.2",
|
|
46
46
|
"@octanejs/vite-plugin": "0.1.61",
|
|
47
47
|
"octane": "0.6.3",
|
|
48
|
-
"tsrx-typegen": "0.2.
|
|
48
|
+
"tsrx-typegen": "0.2.2",
|
|
49
49
|
"typescript": "5.9.3",
|
|
50
50
|
"vite": "8.3.0"
|
|
51
51
|
},
|
package/src/audio.android.ts
CHANGED
|
@@ -26,7 +26,8 @@ declare const com: {
|
|
|
26
26
|
|
|
27
27
|
export const createAudioPlayer = (): AudioPlayer => {
|
|
28
28
|
const actions = com.xplat.audio.AudioBridge
|
|
29
|
-
|
|
29
|
+
// `Utils.android` is a {} stub in the pinned Windows core build.
|
|
30
|
+
const context = (Utils.android as any).getApplicationContext()
|
|
30
31
|
const listeners = new Set<(snapshot: AudioSnapshot) => void>()
|
|
31
32
|
let queue: Track[] = []
|
|
32
33
|
let index = -1
|
package/src/audio.ios.ts
CHANGED
|
@@ -311,7 +311,12 @@ export const createAudioPlayer = (): AudioPlayer => {
|
|
|
311
311
|
nowPlaying.nowPlayingInfo = null as unknown as NSDictionary<string, any>
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
// The Objective-C error-out argument is intentionally null at runtime;
|
|
315
|
+
// NativeScript's generated type only permits Reference<NSError> | undefined.
|
|
316
|
+
const noErrorOut = null as unknown as Parameters<typeof session.setActiveWithOptionsError>[2]
|
|
317
|
+
|
|
318
|
+
session.setActiveWithOptionsError(false, notifyOthersOnDeactivation, noErrorOut)
|
|
319
|
+
|
|
315
320
|
listeners.clear()
|
|
316
321
|
queue = []
|
|
317
322
|
index = -1
|
package/src/audio.web.ts
CHANGED
|
@@ -92,6 +92,7 @@ export const createAudioPlayer = (): AudioPlayer => {
|
|
|
92
92
|
'timeupdate',
|
|
93
93
|
'durationchange',
|
|
94
94
|
'play',
|
|
95
|
+
'playing',
|
|
95
96
|
'pause',
|
|
96
97
|
'ended',
|
|
97
98
|
'waiting',
|
|
@@ -99,6 +100,8 @@ export const createAudioPlayer = (): AudioPlayer => {
|
|
|
99
100
|
]) {
|
|
100
101
|
audio.addEventListener(event, () => {
|
|
101
102
|
if (event === 'play') {
|
|
103
|
+
state = 'loading'
|
|
104
|
+
} else if (event === 'playing') {
|
|
102
105
|
state = 'playing'
|
|
103
106
|
} else if (event === 'pause' && state !== 'ended') {
|
|
104
107
|
state = 'paused'
|