react-native-audio-browser 0.2.0-next.54 → 0.2.0-next.55
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 +32 -19
- package/lib/commonjs/CLAUDE.md +7 -2
- package/lib/commonjs/features/battery.js +16 -12
- package/lib/commonjs/features/battery.js.map +1 -1
- package/lib/commonjs/features/browser-config.js +1 -1
- package/lib/commonjs/features/browser.js +74 -24
- package/lib/commonjs/features/browser.js.map +1 -1
- package/lib/commonjs/features/carConnection.js +3 -4
- package/lib/commonjs/features/carConnection.js.map +1 -1
- package/lib/commonjs/features/equalizer.js +9 -5
- package/lib/commonjs/features/equalizer.js.map +1 -1
- package/lib/commonjs/features/errors.js +35 -21
- package/lib/commonjs/features/errors.js.map +1 -1
- package/lib/commonjs/features/favorites.js +15 -13
- package/lib/commonjs/features/favorites.js.map +1 -1
- package/lib/commonjs/features/gate.js +12 -6
- package/lib/commonjs/features/gate.js.map +1 -1
- package/lib/commonjs/features/metadata.js +16 -14
- package/lib/commonjs/features/metadata.js.map +1 -1
- package/lib/commonjs/features/network.js +5 -1
- package/lib/commonjs/features/network.js.map +1 -1
- package/lib/commonjs/features/nowPlaying.js +28 -14
- package/lib/commonjs/features/nowPlaying.js.map +1 -1
- package/lib/commonjs/features/output.js +8 -4
- package/lib/commonjs/features/output.js.map +1 -1
- package/lib/commonjs/features/playback/controls.js +10 -5
- package/lib/commonjs/features/playback/controls.js.map +1 -1
- package/lib/commonjs/features/playback/playWhenReady.js +6 -5
- package/lib/commonjs/features/playback/playWhenReady.js.map +1 -1
- package/lib/commonjs/features/playback/playing.js +5 -3
- package/lib/commonjs/features/playback/playing.js.map +1 -1
- package/lib/commonjs/features/playback/progress.js +11 -5
- package/lib/commonjs/features/playback/progress.js.map +1 -1
- package/lib/commonjs/features/playback/state.js +3 -3
- package/lib/commonjs/features/playback/state.js.map +1 -1
- package/lib/commonjs/features/playback/trackPlaybackTime.js +6 -1
- package/lib/commonjs/features/playback/trackPlaybackTime.js.map +1 -1
- package/lib/commonjs/features/playback/volume.js +6 -5
- package/lib/commonjs/features/playback/volume.js.map +1 -1
- package/lib/commonjs/features/player/options.js +20 -10
- package/lib/commonjs/features/player/options.js.map +1 -1
- package/lib/commonjs/features/player/setup.js +34 -38
- package/lib/commonjs/features/player/setup.js.map +1 -1
- package/lib/commonjs/features/queue/activeTrack.js +0 -1
- package/lib/commonjs/features/queue/activeTrack.js.map +1 -1
- package/lib/commonjs/features/queue/queue.js +48 -20
- package/lib/commonjs/features/queue/queue.js.map +1 -1
- package/lib/commonjs/features/queue/repeatMode.js +2 -1
- package/lib/commonjs/features/queue/repeatMode.js.map +1 -1
- package/lib/commonjs/features/queue/shuffle.js +0 -1
- package/lib/commonjs/features/queue/shuffle.js.map +1 -1
- package/lib/commonjs/features/remoteControls.js +59 -35
- package/lib/commonjs/features/remoteControls.js.map +1 -1
- package/lib/commonjs/features/sleepTimer.js +15 -6
- package/lib/commonjs/features/sleepTimer.js.map +1 -1
- package/lib/commonjs/utils/LazyNativeEmitter.js +6 -9
- package/lib/commonjs/utils/LazyNativeEmitter.js.map +1 -1
- package/lib/commonjs/utils/NativeUpdatedValue.js +13 -12
- package/lib/commonjs/utils/NativeUpdatedValue.js.map +1 -1
- package/lib/commonjs/utils/getTrackIdentity.js +6 -4
- package/lib/commonjs/utils/getTrackIdentity.js.map +1 -1
- package/lib/commonjs/utils/useDebug.js +16 -3
- package/lib/commonjs/utils/useDebug.js.map +1 -1
- package/lib/commonjs/web/NativeAudioBrowser.js +2 -4
- package/lib/commonjs/web/NativeAudioBrowser.js.map +1 -1
- package/lib/commonjs/web/browser/parseSearchResponse.js +3 -4
- package/lib/commonjs/web/browser/parseSearchResponse.js.map +1 -1
- package/lib/commonjs/web/browser/sections.js +1 -1
- package/lib/commonjs/web/util/BrowserPathHelper.js +1 -3
- package/lib/commonjs/web/util/BrowserPathHelper.js.map +1 -1
- package/lib/module/CLAUDE.md +7 -2
- package/lib/module/features/battery.js +16 -12
- package/lib/module/features/battery.js.map +1 -1
- package/lib/module/features/browser-config.js +1 -1
- package/lib/module/features/browser.js +74 -24
- package/lib/module/features/browser.js.map +1 -1
- package/lib/module/features/carConnection.js +3 -4
- package/lib/module/features/carConnection.js.map +1 -1
- package/lib/module/features/equalizer.js +9 -5
- package/lib/module/features/equalizer.js.map +1 -1
- package/lib/module/features/errors.js +35 -21
- package/lib/module/features/errors.js.map +1 -1
- package/lib/module/features/favorites.js +15 -13
- package/lib/module/features/favorites.js.map +1 -1
- package/lib/module/features/gate.js +12 -6
- package/lib/module/features/gate.js.map +1 -1
- package/lib/module/features/metadata.js +16 -14
- package/lib/module/features/metadata.js.map +1 -1
- package/lib/module/features/network.js +5 -1
- package/lib/module/features/network.js.map +1 -1
- package/lib/module/features/nowPlaying.js +28 -14
- package/lib/module/features/nowPlaying.js.map +1 -1
- package/lib/module/features/output.js +8 -4
- package/lib/module/features/output.js.map +1 -1
- package/lib/module/features/playback/controls.js +10 -5
- package/lib/module/features/playback/controls.js.map +1 -1
- package/lib/module/features/playback/playWhenReady.js +6 -5
- package/lib/module/features/playback/playWhenReady.js.map +1 -1
- package/lib/module/features/playback/playing.js +5 -3
- package/lib/module/features/playback/playing.js.map +1 -1
- package/lib/module/features/playback/progress.js +11 -5
- package/lib/module/features/playback/progress.js.map +1 -1
- package/lib/module/features/playback/state.js +3 -3
- package/lib/module/features/playback/state.js.map +1 -1
- package/lib/module/features/playback/trackPlaybackTime.js +6 -1
- package/lib/module/features/playback/trackPlaybackTime.js.map +1 -1
- package/lib/module/features/playback/volume.js +6 -5
- package/lib/module/features/playback/volume.js.map +1 -1
- package/lib/module/features/player/options.js +20 -10
- package/lib/module/features/player/options.js.map +1 -1
- package/lib/module/features/player/setup.js +34 -38
- package/lib/module/features/player/setup.js.map +1 -1
- package/lib/module/features/queue/activeTrack.js +0 -1
- package/lib/module/features/queue/activeTrack.js.map +1 -1
- package/lib/module/features/queue/queue.js +48 -20
- package/lib/module/features/queue/queue.js.map +1 -1
- package/lib/module/features/queue/repeatMode.js +2 -1
- package/lib/module/features/queue/repeatMode.js.map +1 -1
- package/lib/module/features/queue/shuffle.js +0 -1
- package/lib/module/features/queue/shuffle.js.map +1 -1
- package/lib/module/features/remoteControls.js +59 -35
- package/lib/module/features/remoteControls.js.map +1 -1
- package/lib/module/features/sleepTimer.js +15 -6
- package/lib/module/features/sleepTimer.js.map +1 -1
- package/lib/module/utils/LazyNativeEmitter.js +6 -9
- package/lib/module/utils/LazyNativeEmitter.js.map +1 -1
- package/lib/module/utils/NativeUpdatedValue.js +13 -12
- package/lib/module/utils/NativeUpdatedValue.js.map +1 -1
- package/lib/module/utils/getTrackIdentity.js +6 -4
- package/lib/module/utils/getTrackIdentity.js.map +1 -1
- package/lib/module/utils/useDebug.js +16 -3
- package/lib/module/utils/useDebug.js.map +1 -1
- package/lib/module/web/NativeAudioBrowser.js +2 -4
- package/lib/module/web/NativeAudioBrowser.js.map +1 -1
- package/lib/module/web/browser/parseSearchResponse.js +3 -4
- package/lib/module/web/browser/parseSearchResponse.js.map +1 -1
- package/lib/module/web/browser/sections.js +1 -1
- package/lib/module/web/util/BrowserPathHelper.js +1 -3
- package/lib/module/web/util/BrowserPathHelper.js.map +1 -1
- package/lib/typescript/src/features/battery.d.ts +17 -12
- package/lib/typescript/src/features/battery.d.ts.map +1 -1
- package/lib/typescript/src/features/browser.d.ts +64 -24
- package/lib/typescript/src/features/browser.d.ts.map +1 -1
- package/lib/typescript/src/features/carConnection.d.ts +3 -4
- package/lib/typescript/src/features/carConnection.d.ts.map +1 -1
- package/lib/typescript/src/features/equalizer.d.ts +9 -5
- package/lib/typescript/src/features/equalizer.d.ts.map +1 -1
- package/lib/typescript/src/features/errors.d.ts +37 -22
- package/lib/typescript/src/features/errors.d.ts.map +1 -1
- package/lib/typescript/src/features/favorites.d.ts +15 -13
- package/lib/typescript/src/features/favorites.d.ts.map +1 -1
- package/lib/typescript/src/features/gate.d.ts +14 -8
- package/lib/typescript/src/features/gate.d.ts.map +1 -1
- package/lib/typescript/src/features/metadata.d.ts +37 -17
- package/lib/typescript/src/features/metadata.d.ts.map +1 -1
- package/lib/typescript/src/features/network.d.ts +5 -1
- package/lib/typescript/src/features/network.d.ts.map +1 -1
- package/lib/typescript/src/features/nowPlaying.d.ts +28 -14
- package/lib/typescript/src/features/nowPlaying.d.ts.map +1 -1
- package/lib/typescript/src/features/output.d.ts +8 -4
- package/lib/typescript/src/features/output.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/controls.d.ts +10 -5
- package/lib/typescript/src/features/playback/controls.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/playWhenReady.d.ts +6 -5
- package/lib/typescript/src/features/playback/playWhenReady.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/playing.d.ts +16 -3
- package/lib/typescript/src/features/playback/playing.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/progress.d.ts +11 -5
- package/lib/typescript/src/features/playback/progress.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/state.d.ts +8 -3
- package/lib/typescript/src/features/playback/state.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/trackPlaybackTime.d.ts +9 -2
- package/lib/typescript/src/features/playback/trackPlaybackTime.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/volume.d.ts +6 -5
- package/lib/typescript/src/features/playback/volume.d.ts.map +1 -1
- package/lib/typescript/src/features/player/options.d.ts +52 -37
- package/lib/typescript/src/features/player/options.d.ts.map +1 -1
- package/lib/typescript/src/features/player/setup.d.ts +65 -60
- package/lib/typescript/src/features/player/setup.d.ts.map +1 -1
- package/lib/typescript/src/features/queue/activeTrack.d.ts +0 -1
- package/lib/typescript/src/features/queue/activeTrack.d.ts.map +1 -1
- package/lib/typescript/src/features/queue/queue.d.ts +48 -20
- package/lib/typescript/src/features/queue/queue.d.ts.map +1 -1
- package/lib/typescript/src/features/queue/repeatMode.d.ts +1 -1
- package/lib/typescript/src/features/queue/repeatMode.d.ts.map +1 -1
- package/lib/typescript/src/features/queue/shuffle.d.ts +0 -1
- package/lib/typescript/src/features/queue/shuffle.d.ts.map +1 -1
- package/lib/typescript/src/features/remoteControls.d.ts +58 -25
- package/lib/typescript/src/features/remoteControls.d.ts.map +1 -1
- package/lib/typescript/src/features/sleepTimer.d.ts +15 -7
- package/lib/typescript/src/features/sleepTimer.d.ts.map +1 -1
- package/lib/typescript/src/types/browser-nodes.d.ts +54 -57
- package/lib/typescript/src/types/browser-nodes.d.ts.map +1 -1
- package/lib/typescript/src/types/browser.d.ts +181 -144
- package/lib/typescript/src/types/browser.d.ts.map +1 -1
- package/lib/typescript/src/utils/LazyNativeEmitter.d.ts +6 -9
- package/lib/typescript/src/utils/LazyNativeEmitter.d.ts.map +1 -1
- package/lib/typescript/src/utils/NativeUpdatedValue.d.ts +13 -12
- package/lib/typescript/src/utils/NativeUpdatedValue.d.ts.map +1 -1
- package/lib/typescript/src/utils/getTrackIdentity.d.ts +6 -4
- package/lib/typescript/src/utils/getTrackIdentity.d.ts.map +1 -1
- package/lib/typescript/src/utils/useDebug.d.ts +16 -3
- package/lib/typescript/src/utils/useDebug.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/CLAUDE.md +7 -2
- package/src/docs-floors.test.ts +71 -0
- package/src/features/battery.ts +17 -13
- package/src/features/browser-config.ts +1 -1
- package/src/features/browser.ts +65 -24
- package/src/features/carConnection.ts +3 -4
- package/src/features/equalizer.ts +9 -5
- package/src/features/errors.ts +37 -22
- package/src/features/favorites.ts +15 -13
- package/src/features/gate.ts +14 -8
- package/src/features/metadata.ts +37 -17
- package/src/features/network.ts +5 -1
- package/src/features/nowPlaying.ts +28 -14
- package/src/features/output.ts +8 -4
- package/src/features/playback/controls.ts +10 -5
- package/src/features/playback/playWhenReady.ts +6 -5
- package/src/features/playback/playing.ts +16 -3
- package/src/features/playback/progress.ts +11 -5
- package/src/features/playback/state.ts +8 -3
- package/src/features/playback/trackPlaybackTime.ts +9 -2
- package/src/features/playback/volume.ts +6 -5
- package/src/features/player/options.ts +54 -43
- package/src/features/player/setup.ts +67 -61
- package/src/features/queue/activeTrack.ts +0 -1
- package/src/features/queue/queue.ts +48 -20
- package/src/features/queue/repeatMode.ts +1 -1
- package/src/features/queue/shuffle.ts +0 -1
- package/src/features/remoteControls.ts +59 -35
- package/src/features/sleepTimer.ts +15 -7
- package/src/types/browser-nodes.ts +54 -57
- package/src/types/browser.ts +183 -146
- package/src/utils/LazyNativeEmitter.ts +6 -9
- package/src/utils/NativeUpdatedValue.ts +13 -12
- package/src/utils/getTrackIdentity.ts +6 -4
- package/src/utils/useDebug.ts +16 -3
- package/src/web/NativeAudioBrowser.ts +2 -4
- package/src/web/browser/parseSearchResponse.ts +3 -4
- package/src/web/browser/sections.ts +1 -1
- package/src/web/util/BrowserPathHelper.ts +1 -3
- package/website/guide/android-auto.md +25 -13
- package/website/guide/android-certificates.md +199 -120
- package/website/guide/artwork.md +93 -48
- package/website/guide/audio-output.md +86 -68
- package/website/guide/automotive.md +15 -10
- package/website/guide/basic-usage.md +5 -2
- package/website/guide/battery.md +50 -23
- package/website/guide/browser.md +155 -68
- package/website/guide/carplay.md +132 -49
- package/website/guide/configuration.md +85 -49
- package/website/guide/equalizer.md +36 -32
- package/website/guide/errors.md +106 -64
- package/website/guide/favorites.md +41 -31
- package/website/guide/gate.md +24 -10
- package/website/guide/getting-started.md +55 -2
- package/website/guide/hooks.md +53 -47
- package/website/guide/live-streams.md +80 -49
- package/website/guide/metadata.md +87 -53
- package/website/guide/migrating-from-track-player.md +94 -49
- package/website/guide/native-callback-fetch.md +46 -36
- package/website/guide/network.md +36 -20
- package/website/guide/now-playing.md +72 -44
- package/website/guide/playback.md +112 -35
- package/website/guide/queue.md +77 -43
- package/website/guide/remote-controls.md +87 -29
- package/website/guide/search.md +37 -22
- package/website/guide/sleep-timer.md +35 -14
- package/website/guide/track.md +59 -35
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
type Callback<T> = (arg: T) => void
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The subscription object behind the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* {@link addListener}; the returned function unsubscribes. The emitter is
|
|
8
|
-
* not callable itself.
|
|
4
|
+
* The subscription object behind the remote-control exports (`onRemotePlay`,
|
|
5
|
+
* `onRemoteSeek`, …) and `onGate`. Subscribe with {@link addListener}; the
|
|
6
|
+
* returned function unsubscribes. The emitter is not callable itself.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* instead.
|
|
8
|
+
* Native starts delivering the event only once the first listener is added,
|
|
9
|
+
* and nothing is cached: there is no `lastValue`. The other `on*` exports use
|
|
10
|
+
* `NativeUpdatedValue`, which listens from module load.
|
|
14
11
|
*
|
|
15
12
|
* @example
|
|
16
13
|
* ```typescript
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
type Callback<T> = (arg: T) => void
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The subscription object behind
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
7
|
-
* unsubscribes. The emitter is not callable itself.
|
|
4
|
+
* The subscription object behind most `on*` exports (`onPlaybackChanged`,
|
|
5
|
+
* `onQueueChanged`, `onTrackMetadata`, …). Subscribe with {@link addListener};
|
|
6
|
+
* the returned function unsubscribes. The emitter is not callable itself.
|
|
8
7
|
*
|
|
9
|
-
* It
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
8
|
+
* It listens to native from module load and keeps the latest payload in
|
|
9
|
+
* {@link lastValue}. The remote-control exports and `onGate` use
|
|
10
|
+
* `LazyNativeEmitter`, which listens only once a listener is added.
|
|
11
|
+
*
|
|
12
|
+
* `lastValue` is the last payload native sent, not a fresh reading: it is
|
|
13
|
+
* `undefined` before the first event, and for the queue and active track it
|
|
14
|
+
* can be stale after an in-place change (a favorite toggle). Use the getter
|
|
15
|
+
* (`getQueue`, `getActiveTrack`, …) when you need the current value.
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
16
18
|
* ```typescript
|
|
@@ -27,9 +29,8 @@ export class NativeUpdatedValue<T> {
|
|
|
27
29
|
private listeners = new Set<Callback<T>>()
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
|
-
* The
|
|
31
|
-
*
|
|
32
|
-
* read synchronously at any time.
|
|
32
|
+
* The last payload native sent, or `undefined` before the first. Not a fresh
|
|
33
|
+
* reading: use the matching getter (`getQueue`, …) for the current value.
|
|
33
34
|
*/
|
|
34
35
|
lastValue: T | undefined = undefined
|
|
35
36
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A track's identity: its opaque `id` when present (non-
|
|
3
|
-
* to the playable `src`.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* A track's identity: its opaque `id` when present (non-empty), falling back
|
|
3
|
+
* to the playable `src`. A whitespace-only `id` is the identity here and on
|
|
4
|
+
* iOS, but Android falls back to `src` for it, so never send one. Two tracks
|
|
5
|
+
* refer to the same item exactly when their identities are equal.
|
|
6
|
+
* Browsable-only tracks (neither `id` nor `src`) have no identity — they are
|
|
7
|
+
* addressed by their `path` instead.
|
|
6
8
|
*
|
|
7
9
|
* This is the same comparison the library uses everywhere it matches tracks:
|
|
8
10
|
* favorites (`setFavorites`), the CarPlay / Android Auto "now playing" row
|
package/src/utils/useDebug.ts
CHANGED
|
@@ -126,10 +126,23 @@ function useDebugState(): DebugState {
|
|
|
126
126
|
// MARK: - Main Hook
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
* Debug hook that
|
|
129
|
+
* Debug hook that snapshots the player's state and logs each change.
|
|
130
130
|
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
131
|
+
* Every entry is also written to the console. The log is shared by every
|
|
132
|
+
* mounted `useDebug`: two mounted instances each log the same change, and
|
|
133
|
+
* `clear` empties it for all of them. Position changes under 2 seconds are
|
|
134
|
+
* not logged. `enabled: false` stops only the logging; the hook still
|
|
135
|
+
* subscribes to the state hooks, `useProgress` among them, and re-renders on
|
|
136
|
+
* every change, so remove it from production code rather than disabling it.
|
|
137
|
+
*
|
|
138
|
+
* @param options - Logging options
|
|
139
|
+
* @param options.enabled - Log state changes. Default `__DEV__`.
|
|
140
|
+
* @param options.metadata - Also log `onTrackMetadata`, `onTimedMetadata` and
|
|
141
|
+
* `onChapterMetadata` events. Default `false`.
|
|
142
|
+
* @returns `state`, a summary snapshot (the queue as comma-joined `src`s, the
|
|
143
|
+
* content as its title, errors as their messages); `logs`, the last 100
|
|
144
|
+
* `{ timestamp, elapsed, type, message }` entries; and `clear`, which
|
|
145
|
+
* empties the log.
|
|
133
146
|
*
|
|
134
147
|
* @example
|
|
135
148
|
* ```tsx
|
|
@@ -488,10 +488,8 @@ export class NativeAudioBrowser
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
await this.handleLoad(track, result.tracks, result.startIndex, () => {
|
|
491
|
-
// setQueue
|
|
492
|
-
//
|
|
493
|
-
// skip-to-existing-queue-track path). Without this the first track of a
|
|
494
|
-
// freshly expanded queue loads but stays paused.
|
|
491
|
+
// setQueue stops playback, so start it explicitly: selecting a track
|
|
492
|
+
// is an intent to play (matches the skip-to-existing-queue-track path).
|
|
495
493
|
this.setQueue(result.tracks, result.startIndex)
|
|
496
494
|
this.play()
|
|
497
495
|
})
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { Track } from '../../types'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Normalise a search endpoint's HTTP body into `Track[]`. Endpoints return
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* accepted for back-compat with callback/array-returning sources.
|
|
4
|
+
* Normalise a search endpoint's HTTP body into `Track[]`. Endpoints return a
|
|
5
|
+
* bare `Track[]`, the only shape iOS and Android decode. A page object
|
|
6
|
+
* `{ children: Track[] }` is also accepted here, on web only.
|
|
8
7
|
*/
|
|
9
8
|
export function parseSearchResponse(response: unknown): Track[] {
|
|
10
9
|
if (Array.isArray(response)) return response as Track[]
|
|
@@ -34,7 +34,7 @@ export function flattenedChildren(page: ResolvedTrack): Track[] {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* The section of the page containing the playable `trackId` (a track
|
|
37
|
-
* identity: id when non-
|
|
37
|
+
* identity: id when non-empty, else src), or undefined when not found.
|
|
38
38
|
*
|
|
39
39
|
* `tappedIndex` — the flat page position stamped into the contextual URL —
|
|
40
40
|
* is a tie-breaker, never an identifier: when the child at that position
|
|
@@ -108,10 +108,8 @@ export const BrowserPathHelper = {
|
|
|
108
108
|
* Builds a contextual URL by appending a track identifier — and optionally
|
|
109
109
|
* the tapped child's page position — to a parent path.
|
|
110
110
|
*
|
|
111
|
-
* @param
|
|
112
|
-
* @param trackId The track identity (`id` when non-blank, else `src`)
|
|
111
|
+
* @param trackId The track identity (`id` when non-empty, else `src`)
|
|
113
112
|
* @param index The child's position on the page at stamp time (tie-breaker)
|
|
114
|
-
* @returns A contextual URL combining parent path, track ID, and index
|
|
115
113
|
*
|
|
116
114
|
* Example: build("/library", "song.mp3", 2) → "/library?__trackId=song.mp3&__index=2"
|
|
117
115
|
*/
|
|
@@ -11,7 +11,9 @@ Android Auto shows your [browse tree](/guide/basic-usage) on the car screen and
|
|
|
11
11
|
1. **Browse tree** — Android Auto reads your content from a `MediaBrowserService`, which mirrors your browser routes. The library ships this service.
|
|
12
12
|
2. **Voice search** — "Hey Google, play…" arrives as a `MEDIA_PLAY_FROM_SEARCH` intent, which the library routes to your `search` source.
|
|
13
13
|
|
|
14
|
-
Unlike CarPlay — which needs entitlements and scene delegates — Android Auto needs almost no app-side code.
|
|
14
|
+
Unlike CarPlay — which needs entitlements and scene delegates — Android Auto needs almost no app-side code.
|
|
15
|
+
|
|
16
|
+
The library's own `AndroidManifest.xml` declares the media library service Android Auto binds to, the voice-search intent filter, the content provider that serves browse artwork to the car, and the foreground-service permissions, and those **merge into your app automatically**. You only have to declare your app as an automotive media app.
|
|
15
17
|
|
|
16
18
|
## Setup
|
|
17
19
|
|
|
@@ -35,13 +37,15 @@ Create `android/app/src/main/res/xml/automotive_app_desc.xml`:
|
|
|
35
37
|
</automotiveApp>
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
That's the whole setup.
|
|
40
|
+
That's the whole setup.
|
|
41
|
+
|
|
42
|
+
The rest comes from the [library's manifest](https://github.com/radio-garden/react-native-audio-browser/blob/next/android/src/main/AndroidManifest.xml), which merges into your app, so you don't declare it yourself.
|
|
39
43
|
|
|
40
44
|
## Voice search
|
|
41
45
|
|
|
42
46
|
Google Assistant requests ("play some jazz", "play the radishes") arrive as a `MEDIA_PLAY_FROM_SEARCH` intent. The library normalizes it into the same structured `SearchParams` your in-app and Siri searches use and calls your `search` source — no extra manifest setup, since the library declares the intent filter.
|
|
43
47
|
|
|
44
|
-
Android sends a subset of what iOS does: the query
|
|
48
|
+
Android sends a subset of what iOS does: the query, the `any` / `song` / `playlist` modes, and the genre, artist, album, title and playlist filters, always with `reference: 'unknown'`. See [Search](/guide/search) for how to resolve these requests and the cross-platform differences.
|
|
45
49
|
|
|
46
50
|
## Browse display
|
|
47
51
|
|
|
@@ -53,7 +57,8 @@ Android Auto reads a page's layout from the **parent item** that opens it — be
|
|
|
53
57
|
{
|
|
54
58
|
title: 'Stations',
|
|
55
59
|
path: '/browse/stations',
|
|
56
|
-
|
|
60
|
+
// layout of the page this opens ('list' is the default)
|
|
61
|
+
style: { display: 'grid' },
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
// The page it opens — the ResolvedTrack served for '/browse/stations':
|
|
@@ -65,11 +70,22 @@ Android Auto reads a page's layout from the **parent item** that opens it — be
|
|
|
65
70
|
}
|
|
66
71
|
```
|
|
67
72
|
|
|
68
|
-
- **`style.display` on the parent item** — `'list'` (rows) or `'grid'` (tiles).
|
|
69
|
-
|
|
73
|
+
- **`style.display` on the parent item** — `'list'` (rows) or `'grid'` (tiles). Android Auto decides the page's layout from this before the page resolves, and it is only sent when you declare it. Leave it off and AAOS renders the whole page as a list (see the warning below); projected Android Auto still follows the page's and its sections' `display` item by item.
|
|
74
|
+
|
|
75
|
+
The library logs a warning to Logcat, in debug and release builds, when Android Auto opens an all-grid page whose parent item declares no `display`. (A section's "view all" page needs no declaration of its own: it reuses the section's `style`.)
|
|
76
|
+
|
|
77
|
+
- **Sections** — declare `sections` on the page to group its tracks under headers; each [`Section`](/api/types/browser-nodes/#section)'s `title` renders as a header above its children. A section that carries a `path` also gets a browsable "view more" row appended after its children, navigating there.
|
|
78
|
+
|
|
79
|
+
No header is tappable on Android Auto at any `display`, so the row is the only affordance the section's `path` has here; its title comes from the [`viewMoreTitle`](/api/types/browser/#viewmoretitle) browser option — one wording for every section.
|
|
80
|
+
|
|
81
|
+
For per-section copy (`"View all 42 albums"`), leave `path` unset and append your own browsable `Track` to `children` instead, titled however you like. `children` is shared by every surface, so CarPlay and in-app UIs show that row too; see [`Section`](/api/types/browser-nodes/#section) for how CarPlay draws a section with and without a `path`.
|
|
70
82
|
|
|
71
83
|
::: warning AAOS lays out the whole page from the parent item's `display`
|
|
72
|
-
On AOSP-based Android Automotive units — including mainstream cars' OEM skins — the parent item's `display` is the **only** below-root layout signal honored
|
|
84
|
+
On AOSP-based Android Automotive units — including mainstream cars' OEM skins — the parent item's `display` is the **only** below-root layout signal honored. The whole page renders as list or grid, uniformly.
|
|
85
|
+
|
|
86
|
+
Per-section `display` differences (a single-line grid above a list, say) render on CarPlay and projected Android Auto, but an AAOS unit shows the page in the single declared layout.
|
|
87
|
+
|
|
88
|
+
There is no way to describe a mixed page there — pick the layout that suits its dominant section, or split the content across pages. `gridWrap: false` also has no single-line container there: the grid wraps, showing more, never less.
|
|
73
89
|
:::
|
|
74
90
|
|
|
75
91
|
```ts
|
|
@@ -103,12 +119,8 @@ the car, though:
|
|
|
103
119
|
|
|
104
120
|
Test in a real car, or in Google's **Desktop Head Unit (DHU)** emulator:
|
|
105
121
|
|
|
106
|
-
|
|
107
|
-
2. In the phone's **Android Auto** settings, enable Developer Mode (tap the version 10×), then **"Start head unit server"**.
|
|
108
|
-
3. Connect the phone over USB and run the DHU.
|
|
109
|
-
|
|
110
|
-
See Google's [Test Android Auto apps with DHU](https://developer.android.com/training/cars/testing/dhu) for the full walkthrough. Your app appears under the media apps — browse the tree, exercise voice search, and verify artwork, grid/list styles, and section headers.
|
|
122
|
+
Install the DHU from the SDK Manager, turn on developer mode and the head unit server in the phone's Android Auto app, then connect: Google's [Test Android Auto apps with DHU](https://developer.android.com/training/cars/testing/dhu) has the steps. Your app appears under the media apps — browse the tree, exercise voice search, and verify artwork, grid/list styles, and section headers.
|
|
111
123
|
|
|
112
124
|
## Reference
|
|
113
125
|
|
|
114
|
-
See the [example app](https://github.com/radio-garden/react-native-audio-browser/tree/
|
|
126
|
+
See the [example app](https://github.com/radio-garden/react-native-audio-browser/tree/next/apps/example-native/android) for a complete working manifest and descriptor.
|