react-native-audio-browser 1.0.0-next.2 → 1.0.0-next.4
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/android/src/cast/java/com/audiobrowser/cast/CastSupport.kt +37 -14
- package/android/src/main/java/com/audiobrowser/AudioBrowser.kt +38 -10
- package/android/src/main/java/com/audiobrowser/Service.kt +6 -41
- package/android/src/main/java/com/audiobrowser/browser/BrowserManager.kt +40 -34
- package/android/src/main/java/com/audiobrowser/browser/BrowserUrlResolution.kt +6 -5
- package/android/src/main/java/com/audiobrowser/browser/JsonModels.kt +12 -7
- package/android/src/main/java/com/audiobrowser/extension/QueueIndex.kt +19 -0
- package/android/src/main/java/com/audiobrowser/http/HttpClient.kt +2 -1
- package/android/src/main/java/com/audiobrowser/http/RequestConfigBuilder.kt +32 -18
- package/android/src/main/java/com/audiobrowser/model/PlayerSetupOptions.kt +2 -2
- package/android/src/main/java/com/audiobrowser/player/AutomaticBufferManager.kt +17 -16
- package/android/src/main/java/com/audiobrowser/player/InterceptingPlayer.kt +11 -0
- package/android/src/main/java/com/audiobrowser/player/MediaFactory.kt +5 -1
- package/android/src/main/java/com/audiobrowser/player/MediaSessionCallback.kt +28 -21
- package/android/src/main/java/com/audiobrowser/player/Player.kt +41 -31
- package/android/src/main/java/com/audiobrowser/player/PlayerListener.kt +4 -0
- package/android/src/main/java/com/audiobrowser/player/ResolvingOnReloadSource.kt +38 -0
- package/android/src/main/java/com/audiobrowser/player/TransformingDataSource.kt +34 -19
- package/android/src/main/java/com/audiobrowser/remote/RemotePlayback.kt +10 -1
- package/android/src/main/java/com/audiobrowser/remote/RemoteSwitchingPlayer.kt +48 -4
- package/android/src/main/java/com/audiobrowser/util/BrowserPathHelper.kt +32 -34
- package/android/src/main/java/com/audiobrowser/util/SearchParamsFactory.kt +64 -0
- package/android/src/test/java/com/audiobrowser/ContentRefreshNavigationErrorTest.kt +236 -0
- package/android/src/test/java/com/audiobrowser/NavigateTrackTest.kt +116 -0
- package/android/src/test/java/com/audiobrowser/TestFixtures.kt +41 -0
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerBuildApiRequestTest.kt +21 -4
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerFavoritesTest.kt +49 -0
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerPageShapeTest.kt +93 -0
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerUnparsableResponseTest.kt +82 -0
- package/android/src/test/java/com/audiobrowser/browser/BrowserUrlResolutionTest.kt +27 -0
- package/android/src/test/java/com/audiobrowser/browser/JsonArtworkTest.kt +7 -1
- package/android/src/test/java/com/audiobrowser/browser/JsonFavoritedTest.kt +34 -0
- package/android/src/test/java/com/audiobrowser/browser/JsonStyleTest.kt +6 -6
- package/android/src/test/java/com/audiobrowser/extension/QueueIndexTest.kt +44 -0
- package/android/src/test/java/com/audiobrowser/http/HttpClientTest.kt +34 -0
- package/android/src/test/java/com/audiobrowser/http/RequestConfigBuilderTest.kt +90 -7
- package/android/src/test/java/com/audiobrowser/model/PlayerSetupOptionsTest.kt +19 -2
- package/android/src/test/java/com/audiobrowser/player/AutomaticBufferManagerTest.kt +17 -0
- package/android/src/test/java/com/audiobrowser/player/FavoriteCapabilityTest.kt +41 -0
- package/android/src/test/java/com/audiobrowser/player/MediaFactoryTest.kt +39 -0
- package/android/src/test/java/com/audiobrowser/player/MediaUrlReloadTest.kt +212 -0
- package/android/src/test/java/com/audiobrowser/player/PlayerSeekSnapshotTest.kt +45 -0
- package/android/src/test/java/com/audiobrowser/player/SessionQueueShuffleOrderTest.kt +38 -0
- package/android/src/test/java/com/audiobrowser/player/SessionVoiceSearchTest.kt +173 -0
- package/android/src/test/java/com/audiobrowser/player/TransformingDataSourceTest.kt +127 -1
- package/android/src/test/java/com/audiobrowser/remote/FakeRemote.kt +28 -0
- package/android/src/test/java/com/audiobrowser/remote/RemoteSwitchingPlayerTest.kt +116 -0
- package/android/src/test/java/com/audiobrowser/util/BrowserPathHelperTest.kt +44 -0
- package/android/src/testCast/java/com/audiobrowser/cast/SdkCastRemoteTest.kt +188 -0
- package/ios/Browser/BrowserError.swift +8 -0
- package/ios/Browser/BrowserManager.swift +29 -28
- package/ios/Browser/BrowserPathHelper.swift +26 -24
- package/ios/Browser/FavoriteSet.swift +16 -8
- package/ios/Browser/Favorites.swift +66 -0
- package/ios/Browser/JsonModels.swift +27 -7
- package/ios/Browser/NavigationErrorState.swift +18 -1
- package/ios/Browser/PageResolver.swift +2 -2
- package/ios/Browser/RequestLayer.swift +11 -4
- package/ios/Browser/RequestPipeline.swift +8 -4
- package/ios/Browser/TabBarEntries.swift +7 -0
- package/ios/CarPlay/CarPlayImageLoader.swift +3 -7
- package/ios/CarPlay/CarPlaySession+Navigator.swift +3 -1
- package/ios/CarPlay/IntentHandlers.swift +1 -7
- package/ios/CarPlay/MediaIntentCriteria.swift +4 -4
- package/ios/Extension/CGSize+AspectFit.swift +11 -0
- package/ios/Extension/Dictionary+Headers.swift +8 -0
- package/ios/Extension/NavigationError+Conversion.swift +4 -3
- package/ios/Extension/ResolvedTrack+Copying.swift +15 -0
- package/ios/Http/HttpClient.swift +37 -11
- package/ios/HybridAudioBrowser+Browser.swift +9 -16
- package/ios/HybridAudioBrowser+Options.swift +1 -0
- package/ios/HybridAudioBrowser+Player.swift +24 -23
- package/ios/HybridAudioBrowser+PlayerCallbacks.swift +1 -2
- package/ios/Model/NitroTypeStubs.swift +39 -0
- package/ios/Model/TrackPlayerError.swift +21 -2
- package/ios/Player/AudioSessionController.swift +2 -2
- package/ios/Player/MediaLoader.swift +1 -1
- package/ios/Player/PlaybackStateMachine.swift +1 -2
- package/ios/Player/Player.swift +59 -20
- package/ios/Player/PlayerEngine.swift +5 -0
- package/ios/Player/QueueManager.swift +21 -4
- package/ios/Tests/BrowserErrorTests.swift +21 -0
- package/ios/Tests/BrowserPathHelperTests.swift +18 -0
- package/ios/Tests/CGSizeAspectFitTests.swift +36 -0
- package/ios/Tests/ClampedVolumeTests.swift +26 -0
- package/ios/Tests/FavoriteSetTests.swift +68 -3
- package/ios/Tests/FavoritesTests.swift +102 -0
- package/ios/Tests/HttpClientUserAgentTests.swift +45 -0
- package/ios/Tests/JsonModelsTests.swift +74 -6
- package/ios/Tests/MediaIntentCriteriaTests.swift +11 -1
- package/ios/Tests/MediaLoaderAssetOptionsTests.swift +7 -0
- package/ios/Tests/NavigationErrorStateTests.swift +73 -0
- package/ios/Tests/PlaybackStateMachineTests.swift +6 -4
- package/ios/Tests/PlayerPolicyTests.swift +38 -0
- package/ios/Tests/PlayerProgressTests.swift +109 -0
- package/ios/Tests/PlayerTests.swift +106 -0
- package/ios/Tests/QueueIndexTests.swift +43 -0
- package/ios/Tests/QueueManagerTests.swift +79 -15
- package/ios/Tests/RequestLayerTests.swift +22 -3
- package/ios/Tests/TabBarEntriesTests.swift +19 -0
- package/ios/Tests/TrackSelectorTests.swift +154 -0
- package/ios/Tests/UnparsableResponseTests.swift +91 -0
- package/ios/TrackSelector.swift +28 -8
- package/ios/Util/ArtworkImageFetcher.swift +9 -8
- package/ios/Util/SVGProcessor.swift +6 -17
- package/lib/commonjs/features/browser-config.js +6 -3
- package/lib/commonjs/features/browser-config.js.map +1 -1
- package/lib/commonjs/features/errors.js +12 -7
- package/lib/commonjs/features/errors.js.map +1 -1
- package/lib/commonjs/features/nowPlaying.js +9 -3
- package/lib/commonjs/features/nowPlaying.js.map +1 -1
- package/lib/commonjs/features/playback/controls.js +1 -2
- package/lib/commonjs/features/playback/controls.js.map +1 -1
- package/lib/commonjs/features/playback/trackPlaybackTime.js +2 -1
- package/lib/commonjs/features/playback/trackPlaybackTime.js.map +1 -1
- package/lib/commonjs/features/player/setup.js +2 -2
- package/lib/commonjs/features/queue/activeTrack.js +4 -2
- package/lib/commonjs/features/queue/activeTrack.js.map +1 -1
- package/lib/commonjs/features/sleepTimer.js +6 -5
- package/lib/commonjs/features/sleepTimer.js.map +1 -1
- package/lib/commonjs/utils/LazyNativeEmitter.js +2 -1
- package/lib/commonjs/utils/LazyNativeEmitter.js.map +1 -1
- package/lib/commonjs/utils/NativeUpdatedValue.js +2 -1
- package/lib/commonjs/utils/NativeUpdatedValue.js.map +1 -1
- package/lib/commonjs/utils/callListener.js +23 -0
- package/lib/commonjs/utils/callListener.js.map +1 -0
- package/lib/module/features/browser-config.js +6 -3
- package/lib/module/features/browser-config.js.map +1 -1
- package/lib/module/features/errors.js +12 -7
- package/lib/module/features/errors.js.map +1 -1
- package/lib/module/features/nowPlaying.js +9 -3
- package/lib/module/features/nowPlaying.js.map +1 -1
- package/lib/module/features/playback/controls.js +1 -2
- package/lib/module/features/playback/controls.js.map +1 -1
- package/lib/module/features/playback/trackPlaybackTime.js +2 -1
- package/lib/module/features/playback/trackPlaybackTime.js.map +1 -1
- package/lib/module/features/player/setup.js +2 -2
- package/lib/module/features/queue/activeTrack.js +4 -2
- package/lib/module/features/queue/activeTrack.js.map +1 -1
- package/lib/module/features/sleepTimer.js +6 -5
- package/lib/module/features/sleepTimer.js.map +1 -1
- package/lib/module/utils/LazyNativeEmitter.js +2 -1
- package/lib/module/utils/LazyNativeEmitter.js.map +1 -1
- package/lib/module/utils/NativeUpdatedValue.js +2 -1
- package/lib/module/utils/NativeUpdatedValue.js.map +1 -1
- package/lib/module/utils/callListener.js +19 -0
- package/lib/module/utils/callListener.js.map +1 -0
- package/lib/typescript/src/features/browser-config.d.ts.map +1 -1
- package/lib/typescript/src/features/errors.d.ts +8 -6
- package/lib/typescript/src/features/errors.d.ts.map +1 -1
- package/lib/typescript/src/features/nowPlaying.d.ts +2 -1
- package/lib/typescript/src/features/nowPlaying.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/controls.d.ts +1 -2
- package/lib/typescript/src/features/playback/controls.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/trackPlaybackTime.d.ts.map +1 -1
- package/lib/typescript/src/features/player/setup.d.ts +2 -2
- package/lib/typescript/src/features/queue/activeTrack.d.ts +2 -1
- package/lib/typescript/src/features/queue/activeTrack.d.ts.map +1 -1
- package/lib/typescript/src/features/sleepTimer.d.ts +2 -1
- package/lib/typescript/src/features/sleepTimer.d.ts.map +1 -1
- package/lib/typescript/src/types/browser.d.ts +3 -2
- package/lib/typescript/src/types/browser.d.ts.map +1 -1
- package/lib/typescript/src/utils/LazyNativeEmitter.d.ts.map +1 -1
- package/lib/typescript/src/utils/NativeUpdatedValue.d.ts.map +1 -1
- package/lib/typescript/src/utils/callListener.d.ts +7 -0
- package/lib/typescript/src/utils/callListener.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/features/browser-config.test.ts +15 -0
- package/src/features/browser-config.ts +6 -3
- package/src/features/errors.test.ts +83 -0
- package/src/features/errors.ts +12 -7
- package/src/features/hook-wiring.test.ts +11 -10
- package/src/features/nowPlaying.ts +9 -3
- package/src/features/playback/controls.ts +1 -2
- package/src/features/playback/trackPlaybackTime.test.ts +24 -1
- package/src/features/playback/trackPlaybackTime.ts +2 -1
- package/src/features/player/setup.ts +2 -2
- package/src/features/queue/activeTrack.test.ts +32 -0
- package/src/features/queue/activeTrack.ts +8 -2
- package/src/features/sleepTimer.test.ts +24 -0
- package/src/features/sleepTimer.ts +6 -5
- package/src/types/browser.ts +3 -2
- package/src/utils/LazyNativeEmitter.test.ts +32 -0
- package/src/utils/LazyNativeEmitter.ts +3 -1
- package/src/utils/NativeUpdatedValue.test.ts +32 -0
- package/src/utils/NativeUpdatedValue.ts +3 -1
- package/src/utils/callListener.ts +17 -0
- package/website/guide/configuration.md +3 -3
- package/website/guide/errors.md +3 -1
- package/website/guide/live-streams.md +22 -20
|
@@ -177,14 +177,14 @@ export function useSleepTimer(params?: {
|
|
|
177
177
|
})
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
//
|
|
181
|
-
//
|
|
180
|
+
// Ticks land a whole number of intervals before the deadline, so with
|
|
181
|
+
// secondsLeft rounded up the 0 shows when the timer fires.
|
|
182
182
|
const initialTimeoutId = setTimeout(
|
|
183
183
|
() => {
|
|
184
184
|
update()
|
|
185
185
|
intervalId = setInterval(update, updateInterval)
|
|
186
186
|
},
|
|
187
|
-
|
|
187
|
+
(time - Date.now()) % updateInterval
|
|
188
188
|
)
|
|
189
189
|
let intervalId: ReturnType<typeof setInterval> | undefined
|
|
190
190
|
const clear = () => {
|
|
@@ -202,7 +202,8 @@ export function useSleepTimer(params?: {
|
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
204
|
* State returned by `useSleepTimer` hook.
|
|
205
|
-
* - Time-based timer includes `secondsLeft` countdown
|
|
205
|
+
* - Time-based timer includes `secondsLeft` countdown, rounded up: 0 only
|
|
206
|
+
* once the deadline is reached
|
|
206
207
|
* - End-of-track timer includes `sleepWhenPlayedToEnd` flag
|
|
207
208
|
*/
|
|
208
209
|
export type SleepTimerState =
|
|
@@ -214,7 +215,7 @@ function addSecondsLeft(state: SleepTimer): SleepTimerState | undefined {
|
|
|
214
215
|
if ('time' in state) {
|
|
215
216
|
return {
|
|
216
217
|
...state,
|
|
217
|
-
secondsLeft: Math.max(0, Math.
|
|
218
|
+
secondsLeft: Math.max(0, Math.ceil((state.time - Date.now()) / 1000))
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
221
|
return state
|
package/src/types/browser.ts
CHANGED
|
@@ -1119,8 +1119,9 @@ export type FormattedNavigationError = {
|
|
|
1119
1119
|
* - `'network-error'`: "Network Error" (English)
|
|
1120
1120
|
* - `'http-error'`: the status text, system-localized on iOS (e.g. "Not
|
|
1121
1121
|
* Found", "Service Unavailable"); on Android an English name for common
|
|
1122
|
-
* codes. "Server Error" when there is no status code, for
|
|
1123
|
-
* does not name, and
|
|
1122
|
+
* codes. "Server Error" when there is no status code, for a 2xx (a
|
|
1123
|
+
* response that did not parse), for codes Android does not name, and
|
|
1124
|
+
* always on web
|
|
1124
1125
|
* - `'callback-error'`: "Error" (English)
|
|
1125
1126
|
* - `'empty-content'`: "Nothing here" (English)
|
|
1126
1127
|
* - `'timeout'`: "Couldn't load" (English)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from 'vitest'
|
|
2
|
+
import { LazyNativeEmitter } from './LazyNativeEmitter'
|
|
3
|
+
|
|
4
|
+
afterEach(() => {
|
|
5
|
+
vi.unstubAllGlobals()
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
describe('LazyNativeEmitter', () => {
|
|
9
|
+
it('calls the listeners after one that throws, and rethrows its error from a microtask', () => {
|
|
10
|
+
const rethrown: (() => void)[] = []
|
|
11
|
+
vi.stubGlobal('queueMicrotask', (task: () => void) => rethrown.push(task))
|
|
12
|
+
let emit: (data: string) => void = () => {
|
|
13
|
+
throw new Error('the native slot was never set')
|
|
14
|
+
}
|
|
15
|
+
const emitter = LazyNativeEmitter.emitterize<string>((callback) => {
|
|
16
|
+
emit = callback
|
|
17
|
+
})
|
|
18
|
+
const error = new Error('listener failed')
|
|
19
|
+
const received: string[] = []
|
|
20
|
+
emitter.addListener(() => {
|
|
21
|
+
throw error
|
|
22
|
+
})
|
|
23
|
+
emitter.addListener((data) => received.push(data))
|
|
24
|
+
|
|
25
|
+
emit('first')
|
|
26
|
+
emit('second')
|
|
27
|
+
|
|
28
|
+
expect(received).toEqual(['first', 'second'])
|
|
29
|
+
expect(rethrown).toHaveLength(2)
|
|
30
|
+
expect(rethrown[0]).toThrow(error)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { callListener } from './callListener'
|
|
2
|
+
|
|
1
3
|
type Callback<T> = (arg: T) => void
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -32,7 +34,7 @@ export class LazyNativeEmitter<T> {
|
|
|
32
34
|
const listeners = (this.listeners = new Set())
|
|
33
35
|
this.setter((data: T) => {
|
|
34
36
|
for (const listener of listeners) {
|
|
35
|
-
listener
|
|
37
|
+
callListener(listener, data)
|
|
36
38
|
}
|
|
37
39
|
})
|
|
38
40
|
return listeners
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from 'vitest'
|
|
2
|
+
import { NativeUpdatedValue } from './NativeUpdatedValue'
|
|
3
|
+
|
|
4
|
+
afterEach(() => {
|
|
5
|
+
vi.unstubAllGlobals()
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
describe('NativeUpdatedValue', () => {
|
|
9
|
+
it('calls the listeners after one that throws, and rethrows its error from a microtask', () => {
|
|
10
|
+
const rethrown: (() => void)[] = []
|
|
11
|
+
vi.stubGlobal('queueMicrotask', (task: () => void) => rethrown.push(task))
|
|
12
|
+
let emit: (data: string) => void = () => {
|
|
13
|
+
throw new Error('the native slot was never set')
|
|
14
|
+
}
|
|
15
|
+
const emitter = NativeUpdatedValue.emitterize<string>((callback) => {
|
|
16
|
+
emit = callback
|
|
17
|
+
})
|
|
18
|
+
const error = new Error('listener failed')
|
|
19
|
+
const received: string[] = []
|
|
20
|
+
emitter.addListener(() => {
|
|
21
|
+
throw error
|
|
22
|
+
})
|
|
23
|
+
emitter.addListener((data) => received.push(data))
|
|
24
|
+
|
|
25
|
+
emit('first')
|
|
26
|
+
emit('second')
|
|
27
|
+
|
|
28
|
+
expect(received).toEqual(['first', 'second'])
|
|
29
|
+
expect(rethrown).toHaveLength(2)
|
|
30
|
+
expect(rethrown[0]).toThrow(error)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { callListener } from './callListener'
|
|
2
|
+
|
|
1
3
|
type Callback<T> = (arg: T) => void
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -37,7 +39,7 @@ export class NativeUpdatedValue<T> {
|
|
|
37
39
|
setter((data: T) => {
|
|
38
40
|
this.eventCount++
|
|
39
41
|
for (const listener of this.listeners) {
|
|
40
|
-
listener
|
|
42
|
+
callListener(listener, data)
|
|
41
43
|
}
|
|
42
44
|
})
|
|
43
45
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// React Native's global types lack it; the runtime has it.
|
|
2
|
+
declare function queueMicrotask(callback: () => void): void
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Calls `listener` with `arg`. An error it throws is rethrown from a microtask,
|
|
6
|
+
* so it reaches the global error handler and the caller's loop goes on to the
|
|
7
|
+
* listeners after it.
|
|
8
|
+
*/
|
|
9
|
+
export function callListener<T>(listener: (arg: T) => void, arg: T): void {
|
|
10
|
+
try {
|
|
11
|
+
listener(arg)
|
|
12
|
+
} catch (error) {
|
|
13
|
+
queueMicrotask(() => {
|
|
14
|
+
throw error
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -43,9 +43,9 @@ both platforms. The setup-only fields behave differently on each:
|
|
|
43
43
|
- **Android** reconfigures in place. The fields you pass are merged over the
|
|
44
44
|
previous ones, and the audio engine is only rebuilt when a construction-bound
|
|
45
45
|
field (buffers, wake mode, …) changed. Two fields are exceptions. Left out,
|
|
46
|
-
`remoteOutputs` turns the remote outputs off again, and `nowPlaying`
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
`remoteOutputs` turns the remote outputs off again, and `nowPlaying` goes
|
|
47
|
+
back to `true`: the track's own title and artist replace an earlier
|
|
48
|
+
formatter, so pass the formatter again to keep it.
|
|
49
49
|
- **iOS** replaces the player, built from that call's options alone. The queue
|
|
50
50
|
is cleared, and a setup-only field you leave out (`ios.category`,
|
|
51
51
|
`ios.buffer`, `retry`, …) goes back to its default, so pass the full `ios` and
|
package/website/guide/errors.md
CHANGED
|
@@ -251,6 +251,8 @@ if (error?.retrying) {
|
|
|
251
251
|
_both_ edges of the `'error'` state — entering it (with the error) and leaving
|
|
252
252
|
it (with `error: undefined`; the hook returns `undefined` again). Advisory
|
|
253
253
|
errors never pass through them.
|
|
254
|
+
`getPlaybackError()` is the same snapshot: `undefined` while
|
|
255
|
+
the error is still advisory.
|
|
254
256
|
|
|
255
257
|
The same advisory error also reaches the
|
|
256
258
|
[Now Playing formatter](/guide/now-playing#the-formatter-derived-continuous), so
|
|
@@ -348,7 +350,7 @@ message to render.
|
|
|
348
350
|
|
|
349
351
|
| API | Purpose |
|
|
350
352
|
| ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
351
|
-
| `usePlaybackError()` / `getPlaybackError()` | The current playback error (`{ kind, code, message, statusCode
|
|
353
|
+
| `usePlaybackError()` / `getPlaybackError()` | The current terminal playback error (`{ kind, code, message, statusCode? }`) — branch on `kind`. |
|
|
352
354
|
| `onPlaybackError` | Subscribe to terminal playback errors outside React (fires on entering/leaving `'error'`; advisory retrying errors arrive via `onPlaybackChanged`). |
|
|
353
355
|
| `retry()` | Re-attempt the current item; meant for the `'error'` state (on iOS it reloads from any state). |
|
|
354
356
|
| `setupPlayer({ retry })` | Automatic retry with two [duration budgets](#two-duration-budgets): first-connect and recovery. Off by default. |
|
|
@@ -92,23 +92,26 @@ neither ICY nor HLS ID3. Every web error is terminal.
|
|
|
92
92
|
|
|
93
93
|
If your stream URLs are signed or short-lived, build them in
|
|
94
94
|
[`media.resolve`](/guide/browser#media-and-artwork) — the per-track layer of
|
|
95
|
-
the stream request.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
[
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
the stream request. Every reload of the track re-runs it, so a URL that
|
|
96
|
+
expired while the track was paused or during an outage is re-signed instead
|
|
97
|
+
of re-failing:
|
|
98
|
+
|
|
99
|
+
- a play after a stop, from `'error'`, or after a pause that closed a live
|
|
100
|
+
stream's connection (see [Pausing a live stream](#pausing-a-live-stream));
|
|
101
|
+
- a skip or a repeat that comes back to the track;
|
|
102
|
+
- [`retry()`](/guide/errors#manual-retry), and a
|
|
103
|
+
[live-edge reconnect](#the-live-edge);
|
|
104
|
+
- on iOS and Android, each reconnect of the
|
|
105
|
+
[automatic retry](/guide/errors#automatic-retry). Web has no automatic
|
|
106
|
+
retry.
|
|
107
|
+
|
|
108
|
+
A seek within the open stream doesn't re-run it. On Android, the automatic
|
|
109
|
+
retry of an HLS stream, and a skip or a repeat back to one, reload its
|
|
110
|
+
playlists and segments with the URL and headers already resolved; they re-run
|
|
111
|
+
`media.resolve` only when they request the stream's own URL again (a `src`
|
|
112
|
+
that is itself a media playlist, at its next refresh), or after such a request
|
|
113
|
+
fails. If your resolver calls your backend, each of these
|
|
114
|
+
reconnects waits on that call.
|
|
112
115
|
|
|
113
116
|
```ts
|
|
114
117
|
import { configureBrowser } from 'react-native-audio-browser'
|
|
@@ -139,9 +142,8 @@ On a stream with a seekable live window (HLS with a sliding window) it seeks
|
|
|
139
142
|
to the window's edge; on a non-seekable one (typical ICY radio) it
|
|
140
143
|
reconnects instead — a fresh connection _is_ the live edge.
|
|
141
144
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
fails (see [Fresh URLs on reconnect](#fresh-urls-on-reconnect)).
|
|
145
|
+
The reconnect re-runs `media.resolve` (see
|
|
146
|
+
[Fresh URLs on reconnect](#fresh-urls-on-reconnect)).
|
|
145
147
|
General seeking is in [Playback](/guide/playback).
|
|
146
148
|
|
|
147
149
|
## Pausing a live stream
|