react-native-audio-browser 0.2.0-next.53 → 0.2.0-next.54
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 +8 -10
- package/android/src/main/java/com/audiobrowser/AudioBrowser.kt +96 -243
- package/android/src/main/java/com/audiobrowser/AudioBrowserLifecycleModule.kt +8 -12
- package/android/src/main/java/com/audiobrowser/AudioBrowserPackage.kt +1 -3
- package/android/src/main/java/com/audiobrowser/Callbacks.kt +1 -10
- package/android/src/main/java/com/audiobrowser/ForegroundStart.kt +13 -18
- package/android/src/main/java/com/audiobrowser/HeadlessTaskService.kt +3 -7
- package/android/src/main/java/com/audiobrowser/RemoteOutputs.kt +8 -10
- package/android/src/main/java/com/audiobrowser/Service.kt +20 -61
- package/android/src/main/java/com/audiobrowser/ServiceBinding.kt +9 -17
- package/android/src/main/java/com/audiobrowser/browser/ArtworkResolutionRegistry.kt +10 -9
- package/android/src/main/java/com/audiobrowser/browser/BrowseArtworkRegistry.kt +11 -8
- package/android/src/main/java/com/audiobrowser/browser/BrowserManager.kt +117 -448
- package/android/src/main/java/com/audiobrowser/browser/BrowserUrlResolution.kt +21 -60
- package/android/src/main/java/com/audiobrowser/browser/InertStyleDiagnostic.kt +20 -80
- package/android/src/main/java/com/audiobrowser/browser/JsonArtwork.kt +6 -10
- package/android/src/main/java/com/audiobrowser/browser/JsonModels.kt +7 -24
- package/android/src/main/java/com/audiobrowser/browser/RouteMatch.kt +2 -4
- package/android/src/main/java/com/audiobrowser/browser/SectionScope.kt +13 -31
- package/android/src/main/java/com/audiobrowser/browser/SimpleRouter.kt +12 -40
- package/android/src/main/java/com/audiobrowser/browser/StyleResolver.kt +15 -26
- package/android/src/main/java/com/audiobrowser/browser/TrackLoadHandler.kt +5 -15
- package/android/src/main/java/com/audiobrowser/extension/EnumExtensions.kt +1 -0
- package/android/src/main/java/com/audiobrowser/extension/NumberExt.kt +2 -0
- package/android/src/main/java/com/audiobrowser/extension/ResolvedTrackExt.kt +4 -8
- package/android/src/main/java/com/audiobrowser/extension/TappedTrack.kt +4 -6
- package/android/src/main/java/com/audiobrowser/extension/TrackIdentity.kt +3 -7
- package/android/src/main/java/com/audiobrowser/http/HttpClient.kt +13 -22
- package/android/src/main/java/com/audiobrowser/http/RequestConfigBuilder.kt +17 -38
- package/android/src/main/java/com/audiobrowser/model/IcyTitle.kt +5 -6
- package/android/src/main/java/com/audiobrowser/model/PlaybackMetadata.kt +4 -9
- package/android/src/main/java/com/audiobrowser/model/PlayerSetupOptions.kt +18 -29
- package/android/src/main/java/com/audiobrowser/model/PlayerUpdateOptions.kt +6 -16
- package/android/src/main/java/com/audiobrowser/player/AutomaticBufferManager.kt +15 -45
- package/android/src/main/java/com/audiobrowser/player/CapabilityControls.kt +23 -59
- package/android/src/main/java/com/audiobrowser/player/CrossOriginHeaderStripper.kt +14 -26
- package/android/src/main/java/com/audiobrowser/player/DynamicLoadControl.kt +15 -43
- package/android/src/main/java/com/audiobrowser/player/EnginePlayback.kt +4 -4
- package/android/src/main/java/com/audiobrowser/player/EqualizerController.kt +15 -21
- package/android/src/main/java/com/audiobrowser/player/InterceptingPlayer.kt +14 -31
- package/android/src/main/java/com/audiobrowser/player/LocalEngine.kt +8 -8
- package/android/src/main/java/com/audiobrowser/player/MediaFactory.kt +16 -27
- package/android/src/main/java/com/audiobrowser/player/MediaSessionCallback.kt +119 -237
- package/android/src/main/java/com/audiobrowser/player/MediaSessionCommandManager.kt +48 -145
- package/android/src/main/java/com/audiobrowser/player/NowPlayingUpdater.kt +39 -100
- package/android/src/main/java/com/audiobrowser/player/PlaybackErrorClassifier.kt +16 -26
- package/android/src/main/java/com/audiobrowser/player/PlaybackStateMachine.kt +22 -28
- package/android/src/main/java/com/audiobrowser/player/PlaybackStateStore.kt +28 -64
- package/android/src/main/java/com/audiobrowser/player/PlaybackTimer.kt +8 -4
- package/android/src/main/java/com/audiobrowser/player/Player.kt +117 -405
- package/android/src/main/java/com/audiobrowser/player/PlayerCapabilitiesExt.kt +1 -1
- package/android/src/main/java/com/audiobrowser/player/PlayerEngineFactory.kt +11 -19
- package/android/src/main/java/com/audiobrowser/player/PlayerListener.kt +30 -96
- package/android/src/main/java/com/audiobrowser/player/RetryLoadErrorHandlingPolicy.kt +39 -95
- package/android/src/main/java/com/audiobrowser/player/ShuffleOrderLedBy.kt +7 -13
- package/android/src/main/java/com/audiobrowser/player/SleepTimer.kt +13 -30
- package/android/src/main/java/com/audiobrowser/player/SleepTimerManager.kt +7 -11
- package/android/src/main/java/com/audiobrowser/player/StuckRecoveryPolicy.kt +9 -22
- package/android/src/main/java/com/audiobrowser/player/TransformingDataSource.kt +22 -54
- package/android/src/main/java/com/audiobrowser/player/VolumeFader.kt +8 -15
- package/android/src/main/java/com/audiobrowser/remote/RemoteItem.kt +9 -8
- package/android/src/main/java/com/audiobrowser/remote/RemoteOutputsController.kt +13 -10
- package/android/src/main/java/com/audiobrowser/remote/RemotePlayback.kt +8 -8
- package/android/src/main/java/com/audiobrowser/remote/RemoteQueue.kt +12 -5
- package/android/src/main/java/com/audiobrowser/remote/RemoteSwitchingPlayer.kt +28 -48
- package/android/src/main/java/com/audiobrowser/sonos/DeviceDescriptionParser.kt +11 -19
- package/android/src/main/java/com/audiobrowser/sonos/DidlLite.kt +2 -2
- package/android/src/main/java/com/audiobrowser/sonos/SoapClient.kt +6 -6
- package/android/src/main/java/com/audiobrowser/sonos/SoapEnvelopes.kt +8 -9
- package/android/src/main/java/com/audiobrowser/sonos/SoapResponseParser.kt +11 -18
- package/android/src/main/java/com/audiobrowser/sonos/SonosDiscoverer.kt +10 -10
- package/android/src/main/java/com/audiobrowser/sonos/SonosOutputs.kt +10 -10
- package/android/src/main/java/com/audiobrowser/sonos/SonosPlayer.kt +21 -33
- package/android/src/main/java/com/audiobrowser/sonos/SonosRemote.kt +4 -6
- package/android/src/main/java/com/audiobrowser/sonos/SonosRouteProviderService.kt +9 -10
- package/android/src/main/java/com/audiobrowser/sonos/SonosStreamUri.kt +7 -7
- package/android/src/main/java/com/audiobrowser/sonos/SonosTransport.kt +5 -4
- package/android/src/main/java/com/audiobrowser/sonos/SsdpDiscovery.kt +8 -3
- package/android/src/main/java/com/audiobrowser/sonos/SsdpMessages.kt +4 -6
- package/android/src/main/java/com/audiobrowser/sonos/ZoneGroupState.kt +13 -11
- package/android/src/main/java/com/audiobrowser/tls/AiaCertChaser.kt +34 -71
- package/android/src/main/java/com/audiobrowser/tls/AiaChasingExtendedTrustManager.kt +20 -37
- package/android/src/main/java/com/audiobrowser/tls/AiaChasingTrustManager.kt +18 -27
- package/android/src/main/java/com/audiobrowser/tls/AiaTls.kt +14 -29
- package/android/src/main/java/com/audiobrowser/tls/CachingCertificateFetcher.kt +68 -133
- package/android/src/main/java/com/audiobrowser/util/ArtworkContentProvider.kt +10 -22
- package/android/src/main/java/com/audiobrowser/util/ArtworkRoutes.kt +6 -6
- package/android/src/main/java/com/audiobrowser/util/ArtworkUris.kt +4 -3
- package/android/src/main/java/com/audiobrowser/util/ArtworkVariant.kt +2 -13
- package/android/src/main/java/com/audiobrowser/util/Automotive.kt +2 -4
- package/android/src/main/java/com/audiobrowser/util/BatteryOptimizationHelper.kt +3 -9
- package/android/src/main/java/com/audiobrowser/util/BatteryWarningStore.kt +4 -14
- package/android/src/main/java/com/audiobrowser/util/BrowserPathHelper.kt +21 -85
- package/android/src/main/java/com/audiobrowser/util/CoilArtworkLoader.kt +7 -7
- package/android/src/main/java/com/audiobrowser/util/CoilArtworkLoaderHolder.kt +5 -8
- package/android/src/main/java/com/audiobrowser/util/CoilBitmapLoader.kt +8 -24
- package/android/src/main/java/com/audiobrowser/util/EqualizerManager.kt +7 -39
- package/android/src/main/java/com/audiobrowser/util/MediaExtrasBuilder.kt +10 -14
- package/android/src/main/java/com/audiobrowser/util/MetadataAdapter.kt +5 -9
- package/android/src/main/java/com/audiobrowser/util/NetworkConnectivityMonitor.kt +5 -9
- package/android/src/main/java/com/audiobrowser/util/OutputMonitor.kt +21 -50
- package/android/src/main/java/com/audiobrowser/util/OutputSwitcher.kt +7 -20
- package/android/src/main/java/com/audiobrowser/util/PlayingStateFactory.kt +3 -5
- package/android/src/main/java/com/audiobrowser/util/RatingFavorites.kt +4 -5
- package/android/src/main/java/com/audiobrowser/util/StyleWire.kt +5 -5
- package/android/src/main/java/com/audiobrowser/util/SvgArtworkRenderer.kt +5 -9
- package/android/src/main/java/com/audiobrowser/util/SystemVolumeMonitor.kt +6 -9
- package/android/src/main/java/com/audiobrowser/util/TrackFactory.kt +25 -47
- package/android/src/nocast/java/com/audiobrowser/cast/CastSupport.kt +0 -2
- package/android/src/test/java/com/audiobrowser/ForegroundStartTest.kt +1 -2
- package/android/src/test/java/com/audiobrowser/LegacyRatingTest.kt +3 -3
- package/android/src/test/java/com/audiobrowser/ServiceBindingTest.kt +0 -13
- package/android/src/test/java/com/audiobrowser/ServiceTaskRemovedTest.kt +2 -3
- package/android/src/test/java/com/audiobrowser/TestFixtures.kt +5 -14
- package/android/src/test/java/com/audiobrowser/browser/BrowseArtworkRegistryTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerBuildApiRequestTest.kt +2 -8
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerFavoritesTest.kt +2 -12
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerLayerResolutionTest.kt +5 -28
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerTest.kt +11 -43
- package/android/src/test/java/com/audiobrowser/browser/BrowserUrlResolutionTest.kt +4 -13
- package/android/src/test/java/com/audiobrowser/browser/InertStyleDiagnosticTest.kt +2 -11
- package/android/src/test/java/com/audiobrowser/browser/JsonArtworkTest.kt +0 -2
- package/android/src/test/java/com/audiobrowser/browser/JsonStyleTest.kt +3 -8
- package/android/src/test/java/com/audiobrowser/browser/SectionScopeTest.kt +2 -14
- package/android/src/test/java/com/audiobrowser/browser/SimpleRouterTest.kt +1 -5
- package/android/src/test/java/com/audiobrowser/browser/StyleResolverTest.kt +2 -13
- package/android/src/test/java/com/audiobrowser/extension/TappedTrackTest.kt +1 -7
- package/android/src/test/java/com/audiobrowser/extension/TrackIdentityTest.kt +0 -5
- package/android/src/test/java/com/audiobrowser/http/RequestConfigBuilderTest.kt +8 -16
- package/android/src/test/java/com/audiobrowser/model/IcyTitleTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/player/BrowseTilesTest.kt +12 -29
- package/android/src/test/java/com/audiobrowser/player/CapabilityControlsTest.kt +3 -12
- package/android/src/test/java/com/audiobrowser/player/CrossOriginHeaderStripperTest.kt +0 -7
- package/android/src/test/java/com/audiobrowser/player/DynamicLoadControlTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/player/EqualizerControllerTest.kt +0 -9
- package/android/src/test/java/com/audiobrowser/player/LiveSeekCommandTest.kt +1 -2
- package/android/src/test/java/com/audiobrowser/player/MediaSessionSlotMappingTest.kt +0 -9
- package/android/src/test/java/com/audiobrowser/player/NowPlayingUpdaterTest.kt +15 -22
- package/android/src/test/java/com/audiobrowser/player/PlaybackErrorClassifierTest.kt +1 -24
- package/android/src/test/java/com/audiobrowser/player/PlaybackStateMachineTest.kt +0 -20
- package/android/src/test/java/com/audiobrowser/player/PlaybackStateStoreTrackJsonTest.kt +1 -6
- package/android/src/test/java/com/audiobrowser/player/PlaybackTimerTest.kt +2 -4
- package/android/src/test/java/com/audiobrowser/player/PlayerCastTest.kt +2 -2
- package/android/src/test/java/com/audiobrowser/player/PlayerEngineFactoryTest.kt +0 -3
- package/android/src/test/java/com/audiobrowser/player/PlayerInvalidTrackTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/player/PlayerSetupTest.kt +3 -2
- package/android/src/test/java/com/audiobrowser/player/PlayerSonosTest.kt +5 -1
- package/android/src/test/java/com/audiobrowser/player/PlayerSuppressionTest.kt +5 -7
- package/android/src/test/java/com/audiobrowser/player/RetryLoadErrorHandlingPolicyTest.kt +4 -35
- package/android/src/test/java/com/audiobrowser/player/SessionErrorMaskTest.kt +0 -5
- package/android/src/test/java/com/audiobrowser/player/ShuffleOrderLedByTest.kt +1 -8
- package/android/src/test/java/com/audiobrowser/player/StandardSkipTest.kt +4 -6
- package/android/src/test/java/com/audiobrowser/player/StuckRecoveryPolicyTest.kt +11 -11
- package/android/src/test/java/com/audiobrowser/player/TransformingDataSourceTest.kt +2 -23
- package/android/src/test/java/com/audiobrowser/remote/FakeRemote.kt +9 -10
- package/android/src/test/java/com/audiobrowser/remote/RemoteSwitchingPlayerTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/DeviceDescriptionParserTest.kt +1 -3
- package/android/src/test/java/com/audiobrowser/sonos/DidlLiteTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/SoapClientTest.kt +0 -3
- package/android/src/test/java/com/audiobrowser/sonos/SoapEnvelopesTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/SoapResponseParserTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/SonosDiscovererTest.kt +2 -0
- package/android/src/test/java/com/audiobrowser/sonos/SonosPlayerTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/SonosRemoteTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/sonos/SonosRoutesTest.kt +2 -0
- package/android/src/test/java/com/audiobrowser/sonos/SonosTransportTest.kt +2 -6
- package/android/src/test/java/com/audiobrowser/sonos/SsdpMessagesTest.kt +0 -2
- package/android/src/test/java/com/audiobrowser/tls/AiaCertChaserTest.kt +13 -37
- package/android/src/test/java/com/audiobrowser/tls/AiaChasingTrustManagerTest.kt +10 -24
- package/android/src/test/java/com/audiobrowser/tls/CachingCertificateFetcherCallSiteTest.kt +15 -39
- package/android/src/test/java/com/audiobrowser/tls/CachingCertificateFetcherTest.kt +4 -10
- package/android/src/test/java/com/audiobrowser/util/ArtworkContentProviderTest.kt +2 -11
- package/android/src/test/java/com/audiobrowser/util/ArtworkUrisTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/util/BrowserPathHelperTest.kt +0 -4
- package/android/src/test/java/com/audiobrowser/util/CoilArtworkLoaderHolderTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/util/CoilArtworkLoaderTest.kt +0 -5
- package/android/src/test/java/com/audiobrowser/util/FakeImageLoader.kt +2 -2
- package/android/src/test/java/com/audiobrowser/util/MediaExtrasBuilderTest.kt +4 -12
- package/android/src/test/java/com/audiobrowser/util/OutputMonitorTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/util/PlayingStateFactoryTest.kt +0 -4
- package/android/src/test/java/com/audiobrowser/util/TrackFactoryBrowseTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/util/TrackFactoryMediaIdTest.kt +4 -6
- package/android/src/testCast/java/com/audiobrowser/cast/CastEndsTest.kt +1 -1
- package/android/src/testCast/java/com/audiobrowser/cast/SendingMediaItemConverterTest.kt +1 -0
- package/ios/AVPlayerEngine.swift +13 -21
- package/ios/AVPlayerEngineCallbacks.swift +2 -4
- package/ios/Browser/BrowseGate.swift +7 -8
- package/ios/Browser/BrowserConfig.swift +19 -34
- package/ios/Browser/BrowserError.swift +0 -1
- package/ios/Browser/BrowserManager.swift +29 -75
- package/ios/Browser/BrowserPathHelper.swift +13 -93
- package/ios/Browser/FavoriteSet.swift +7 -10
- package/ios/Browser/InertStyleDiagnostic.swift +17 -82
- package/ios/Browser/JsonModels.swift +11 -51
- package/ios/Browser/NavigationErrorState.swift +3 -2
- package/ios/Browser/PageResolver.swift +13 -23
- package/ios/Browser/RequestLayer.swift +16 -20
- package/ios/Browser/RequestPipeline.swift +33 -43
- package/ios/Browser/SearchDrillIn.swift +7 -13
- package/ios/Browser/SectionScope.swift +14 -26
- package/ios/Browser/SimpleRouter.swift +8 -15
- package/ios/Browser/StyleResolver.swift +12 -29
- package/ios/Browser/TabBarEntries.swift +6 -11
- package/ios/Browser/TrackIdTemplate.swift +6 -14
- package/ios/CarPlay/CPInterfaceController+Safe.swift +19 -28
- package/ios/CarPlay/CarPlayArtworkResolver.swift +5 -9
- package/ios/CarPlay/CarPlayController.swift +4 -4
- package/ios/CarPlay/CarPlayImageLoader.swift +11 -26
- package/ios/CarPlay/CarPlayListItemFactory.swift +30 -80
- package/ios/CarPlay/CarPlayNowPlayingManager.swift +19 -54
- package/ios/CarPlay/CarPlaySession+Navigator.swift +10 -10
- package/ios/CarPlay/CarPlaySession+PageLoader.swift +6 -5
- package/ios/CarPlay/CarPlaySession+Refresher.swift +2 -2
- package/ios/CarPlay/CarPlaySession+TabBar.swift +19 -26
- package/ios/CarPlay/CarPlaySession.swift +13 -17
- package/ios/CarPlay/CarPlayTemplates.swift +6 -7
- package/ios/CarPlay/IntentHandlers.swift +3 -5
- package/ios/CarPlay/MediaIntentCriteria.swift +15 -29
- package/ios/CarPlay/MediaIntentHandler.swift +4 -7
- package/ios/CarPlay/MediaIntentPlayback.swift +9 -8
- package/ios/CarPlay/NowPlayingButtonRules.swift +3 -4
- package/ios/CarPlay/SectionPresentation.swift +18 -28
- package/ios/CarPlay/TopTemplateReplacer.swift +8 -9
- package/ios/Extension/Capability+RemoteCommand.swift +3 -3
- package/ios/Extension/ChapterMetadata+AVFoundation.swift +2 -5
- package/ios/Extension/CxxVectorConformances.swift +4 -16
- package/ios/Extension/NavigationError+Conversion.swift +4 -7
- package/ios/Extension/PlayerCapabilities+Favorite.swift +0 -1
- package/ios/Extension/RequestConfig+Copying.swift +2 -6
- package/ios/Extension/ResolvedTrack+Copying.swift +2 -8
- package/ios/Extension/SearchParams+Query.swift +4 -4
- package/ios/Extension/Section+Copying.swift +3 -6
- package/ios/Extension/String+IcyCharset.swift +5 -5
- package/ios/Extension/TimedMetadata+AVFoundation.swift +6 -12
- package/ios/Extension/Track+AVPlayer.swift +1 -2
- package/ios/Extension/Track+Copying.swift +2 -8
- package/ios/Extension/Track+Identity.swift +4 -9
- package/ios/Extension/TrackMetadata+AVFoundation.swift +10 -13
- package/ios/Extension/UIApplication+ActiveScene.swift +6 -14
- package/ios/Extension/Variant+Artwork.swift +8 -22
- package/ios/Http/HttpClient.swift +3 -3
- package/ios/HybridAudioBrowser+Browser.swift +10 -16
- package/ios/HybridAudioBrowser+Options.swift +6 -9
- package/ios/HybridAudioBrowser+Player.swift +8 -16
- package/ios/HybridAudioBrowser+PlayerCallbacks.swift +4 -5
- package/ios/HybridAudioBrowser+Stubs.swift +5 -7
- package/ios/HybridAudioBrowser.swift +54 -79
- package/ios/Model/NitroTypeStubs.swift +15 -22
- package/ios/Model/PlayerUpdateOptions.swift +6 -21
- package/ios/Model/RemoteCommand.swift +2 -2
- package/ios/Model/TrackPlayerError.swift +9 -22
- package/ios/NowPlayingInfo/NowPlayingInfoController.swift +21 -40
- package/ios/NowPlayingInfo/SilentAudioPrimer.swift +10 -16
- package/ios/Observer/ItemObserver.swift +7 -5
- package/ios/Observer/PlayerObserver.swift +5 -5
- package/ios/PlaybackEvent.swift +2 -2
- package/ios/Player/AirPlayStallJudgement.swift +7 -9
- package/ios/Player/AudioSessionController.swift +14 -15
- package/ios/Player/DeferredSeek.swift +2 -2
- package/ios/Player/EndOfTrackJudgement.swift +6 -13
- package/ios/Player/ErrorStatus.swift +8 -7
- package/ios/Player/MediaLoader.swift +20 -24
- package/ios/Player/NowPlayingLines.swift +1 -4
- package/ios/Player/NowPlayingUpdater.swift +35 -61
- package/ios/Player/PersistedPlaybackState.swift +1 -2
- package/ios/Player/PlaybackFailure.swift +20 -24
- package/ios/Player/PlaybackPersistence.swift +5 -6
- package/ios/Player/PlaybackStateMachine.swift +8 -11
- package/ios/Player/PlaybackTimer.swift +8 -11
- package/ios/Player/Player.swift +6 -13
- package/ios/Player/PlayerEngine.swift +20 -20
- package/ios/Player/PlayerStatusTypes.swift +1 -2
- package/ios/Player/QueueManager.swift +23 -67
- package/ios/Player/RetryLoop.swift +39 -50
- package/ios/Player/ShuffleOrder.swift +17 -57
- package/ios/Player/SleepTimerManager.swift +13 -28
- package/ios/Player/VolumeFader.swift +16 -16
- package/ios/RemoteCommand/RemoteCommandCallbacks.swift +6 -16
- package/ios/RemoteCommand/RemoteCommandController.swift +8 -10
- package/ios/Tests/AirPlayStallJudgementTests.swift +4 -4
- package/ios/Tests/BrowserPathHelperTests.swift +3 -6
- package/ios/Tests/DeferredSeekTests.swift +1 -3
- package/ios/Tests/EmitterTests.swift +0 -1
- package/ios/Tests/EndOfTrackJudgementTests.swift +1 -6
- package/ios/Tests/FavoriteSetTests.swift +1 -0
- package/ios/Tests/GenerationMemoTests.swift +2 -2
- package/ios/Tests/InertStyleDiagnosticTests.swift +4 -10
- package/ios/Tests/JsonModelsTests.swift +5 -12
- package/ios/Tests/LRUCacheTests.swift +1 -5
- package/ios/Tests/MediaIntentCriteriaTests.swift +2 -7
- package/ios/Tests/MediaLoaderTests.swift +3 -12
- package/ios/Tests/ObserverTests.swift +3 -3
- package/ios/Tests/PlaybackErrorTests.swift +7 -9
- package/ios/Tests/PlaybackFailureTests.swift +9 -17
- package/ios/Tests/PlaybackPersistenceTests.swift +1 -0
- package/ios/Tests/PlaybackStateMachineTests.swift +1 -16
- package/ios/Tests/PlaybackTimerTests.swift +2 -3
- package/ios/Tests/PlayerPolicyTests.swift +10 -26
- package/ios/Tests/PlayerTests.swift +53 -88
- package/ios/Tests/PlayingStateTests.swift +0 -1
- package/ios/Tests/QueueManagerTests.swift +30 -80
- package/ios/Tests/RemoteCommandControllerTests.swift +5 -13
- package/ios/Tests/ResolvedTrackCopyingTests.swift +0 -2
- package/ios/Tests/RetryLoopTests.swift +12 -35
- package/ios/Tests/SearchDrillInTests.swift +4 -5
- package/ios/Tests/SectionPresentationTests.swift +3 -16
- package/ios/Tests/SectionScopeTests.swift +3 -6
- package/ios/Tests/SimpleRouterTests.swift +1 -5
- package/ios/Tests/SleepTimerManagerTests.swift +8 -11
- package/ios/Tests/StyleResolverTests.swift +4 -13
- package/ios/Tests/Support/ManualSleepTimerScheduler.swift +3 -8
- package/ios/Tests/Support/TestTypes.swift +5 -15
- package/ios/Tests/TabBarEntriesTests.swift +0 -2
- package/ios/Tests/TimedMetadataAVFoundationTests.swift +2 -3
- package/ios/Tests/TopTemplateReplacerTests.swift +1 -1
- package/ios/Tests/TrackIdTemplateTests.swift +2 -6
- package/ios/Tests/TrackMetadataAVFoundationTests.swift +1 -4
- package/ios/Tests/TrackSelectorTests.swift +3 -15
- package/ios/TrackSelector.swift +13 -25
- package/ios/Util/ArtworkFreshness.swift +6 -6
- package/ios/Util/ArtworkImageFetcher.swift +19 -20
- package/ios/Util/ConcurrentMap.swift +2 -2
- package/ios/Util/Emitter.swift +8 -13
- package/ios/Util/NetworkMonitor.swift +4 -6
- package/ios/Util/OutputPicker.swift +1 -1
- package/ios/Util/ReadyValue.swift +3 -2
- package/ios/Util/SFSymbolRenderer.swift +17 -30
- package/ios/Util/SVGProcessor.swift +5 -9
- package/package.json +1 -1
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
package com.audiobrowser.browser
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - /artists/{id}/albums - multiple segments with parameters
|
|
10
|
-
* - /artists/* - wildcard match (matches any single segment)
|
|
11
|
-
* - /files/** - tail wildcard (matches remaining path segments)
|
|
12
|
-
*
|
|
13
|
-
* Route specificity rules:
|
|
14
|
-
* - More path segments = higher specificity
|
|
15
|
-
* - Constant segments > parameter segments > wildcards > tail wildcards
|
|
16
|
-
* - Most specific route wins
|
|
4
|
+
* Matches paths against route patterns segment by segment; empty segments are ignored, so leading
|
|
5
|
+
* and trailing slashes don't matter. In a pattern, `{name}` captures one segment into
|
|
6
|
+
* `params[name]`, `*` matches one segment without capturing it, a final `**` matches zero or more
|
|
7
|
+
* remaining segments and captures them, joined with `/`, as `params["tail"]` when there is at least
|
|
8
|
+
* one, and anything else must match exactly.
|
|
17
9
|
*/
|
|
18
10
|
class SimpleRouter {
|
|
19
11
|
|
|
20
12
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
13
|
+
* Returns the pattern in [routes] that matches [path] with the highest specificity, and its
|
|
14
|
+
* match, or null when none matches. Ranks mostly by constant segments, then `{param}`s, then `*`s
|
|
15
|
+
* (weights 1000/100/10); then a trailing `**` adds one, and each pattern segment (the `**`
|
|
16
|
+
* included) adds one, so `/a/{x}` with a trailing `**` beats `/a/{x}` even when the path ends at
|
|
17
|
+
* `{x}`. Among equal scores, the first in [routes]' iteration order wins.
|
|
26
18
|
*/
|
|
27
19
|
fun <T> findBestMatch(path: String, routes: Map<String, T>): Pair<String, RouteMatch>? {
|
|
28
20
|
return routes.keys
|
|
@@ -30,13 +22,6 @@ class SimpleRouter {
|
|
|
30
22
|
.maxByOrNull { (_, match) -> match.specificity }
|
|
31
23
|
}
|
|
32
24
|
|
|
33
|
-
/**
|
|
34
|
-
* Attempts to match a single pattern against a path.
|
|
35
|
-
*
|
|
36
|
-
* @param pattern Route pattern (e.g., "/artists/{id}", "/files/*", "/api/**")
|
|
37
|
-
* @param path Incoming path (e.g., "/artists/123")
|
|
38
|
-
* @return RouteMatch if successful, null otherwise
|
|
39
|
-
*/
|
|
40
25
|
private fun matchPattern(pattern: String, path: String): RouteMatch? {
|
|
41
26
|
val patternSegments = pattern.split('/').filter { it.isNotEmpty() }
|
|
42
27
|
val pathSegments = path.split('/').filter { it.isNotEmpty() }
|
|
@@ -47,16 +32,13 @@ class SimpleRouter {
|
|
|
47
32
|
var wildcardSegments = 0
|
|
48
33
|
var hasTailWildcard = false
|
|
49
34
|
|
|
50
|
-
// Check for tail wildcard at end
|
|
51
35
|
if (patternSegments.isNotEmpty() && patternSegments.last() == "**") {
|
|
52
36
|
hasTailWildcard = true
|
|
53
37
|
|
|
54
|
-
// For tail wildcard, pattern must have <= path segments
|
|
55
38
|
if (patternSegments.size - 1 > pathSegments.size) {
|
|
56
39
|
return null
|
|
57
40
|
}
|
|
58
41
|
|
|
59
|
-
// Match all segments except the tail wildcard
|
|
60
42
|
for (i in 0 until patternSegments.size - 1) {
|
|
61
43
|
if (!matchSingleSegment(patternSegments[i], pathSegments[i], params)) {
|
|
62
44
|
return null
|
|
@@ -73,13 +55,11 @@ class SimpleRouter {
|
|
|
73
55
|
wildcardSegments = wildcardCount
|
|
74
56
|
}
|
|
75
57
|
|
|
76
|
-
// Capture remaining path segments as "tail" parameter
|
|
77
58
|
if (pathSegments.size > patternSegments.size - 1) {
|
|
78
59
|
val remainingSegments = pathSegments.drop(patternSegments.size - 1)
|
|
79
60
|
params["tail"] = remainingSegments.joinToString("/")
|
|
80
61
|
}
|
|
81
62
|
} else {
|
|
82
|
-
// Normal matching - must have same number of segments
|
|
83
63
|
if (patternSegments.size != pathSegments.size) {
|
|
84
64
|
return null
|
|
85
65
|
}
|
|
@@ -101,12 +81,8 @@ class SimpleRouter {
|
|
|
101
81
|
}
|
|
102
82
|
}
|
|
103
83
|
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
// - Parameters: 100 points each
|
|
107
|
-
// - Single wildcards: 10 points each
|
|
108
|
-
// - Tail wildcard: 1 point
|
|
109
|
-
// - Base path length: segments count
|
|
84
|
+
// Weights, not a strict order: the lower terms add up, so enough `{param}`s and `*`s (e.g. 9 of
|
|
85
|
+
// each) can outscore one more constant.
|
|
110
86
|
val specificity =
|
|
111
87
|
(constantSegments * 1000) +
|
|
112
88
|
(parameterSegments * 100) +
|
|
@@ -123,17 +99,13 @@ class SimpleRouter {
|
|
|
123
99
|
params: MutableMap<String, String>,
|
|
124
100
|
): Boolean {
|
|
125
101
|
return when {
|
|
126
|
-
// Parameter segment: {paramName}
|
|
127
102
|
patternSegment.startsWith('{') && patternSegment.endsWith('}') -> {
|
|
128
103
|
val paramName = patternSegment.substring(1, patternSegment.length - 1)
|
|
129
104
|
params[paramName] = pathSegment
|
|
130
105
|
true
|
|
131
106
|
}
|
|
132
|
-
// Single wildcard: *
|
|
133
107
|
patternSegment == "*" -> true
|
|
134
|
-
// Constant segment: must match exactly
|
|
135
108
|
patternSegment == pathSegment -> true
|
|
136
|
-
// Mismatch
|
|
137
109
|
else -> false
|
|
138
110
|
}
|
|
139
111
|
}
|
|
@@ -4,27 +4,16 @@ import com.margelo.nitro.audiobrowser.SectionStyle
|
|
|
4
4
|
import com.margelo.nitro.audiobrowser.TrackStyle
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Resolves style declarations to effective values, per property. Item properties resolve `track ??
|
|
8
|
+
* section ?? page`. Container properties and the positional `display` resolve `section ?? page` and
|
|
9
|
+
* never inherit onto an item. See docs/adr/0011-style-is-a-declaration-block.md.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - **Container properties and the positional `display`** resolve by scope override: `section ??
|
|
13
|
-
* page` — the page declares for its whole scope, a section overrides for its own children.
|
|
14
|
-
* `display` is never inherited item-to-container: each holder describes its own children, and a
|
|
15
|
-
* track's `display` is the promise for the page *it* opens, not its rendering inside this
|
|
16
|
-
* section.
|
|
17
|
-
*
|
|
18
|
-
* Every key of `SectionStyle` must be read by [sectionStyle] and every inherited key of
|
|
19
|
-
* `TrackStyle` by [trackStyle] — Nitro flattens the spec's `extends`, so
|
|
20
|
-
* `src/style-resolution.test.ts` enforces this completeness, not the type system.
|
|
11
|
+
* Nitro flattens the spec's `extends`, so the type system does not make these functions read every
|
|
12
|
+
* key; `src/style-resolution.test.ts` does. A key added to `SectionStyle` must be read by
|
|
13
|
+
* [sectionStyle], and an inherited key added to `TrackStyle` by [trackStyle].
|
|
21
14
|
*/
|
|
22
15
|
object StyleResolver {
|
|
23
|
-
/**
|
|
24
|
-
* Folds the page block into a section's block: every `SectionStyle` key resolves `section ??
|
|
25
|
-
* page`. The result is the section's effective block; item resolution then only needs `track ??
|
|
26
|
-
* section`.
|
|
27
|
-
*/
|
|
16
|
+
/** Folds the page block into a section's block, so item resolution only needs the section. */
|
|
28
17
|
fun sectionStyle(section: SectionStyle?, page: SectionStyle?): SectionStyle =
|
|
29
18
|
SectionStyle(
|
|
30
19
|
display = section?.display ?: page?.display,
|
|
@@ -38,21 +27,21 @@ object StyleResolver {
|
|
|
38
27
|
)
|
|
39
28
|
|
|
40
29
|
/**
|
|
41
|
-
* Resolves a track's
|
|
30
|
+
* Resolves a track's item properties against its section block, already folded by [sectionStyle].
|
|
31
|
+
* The result's `display` is always null.
|
|
42
32
|
*
|
|
43
|
-
* No Android renderer
|
|
44
|
-
*
|
|
45
|
-
* completeness test can hold every future inherited key to the same rule from day one.
|
|
33
|
+
* No Android renderer reads the result yet; it exists so the completeness test holds both
|
|
34
|
+
* platforms to the same rule.
|
|
46
35
|
*/
|
|
47
36
|
fun trackStyle(track: TrackStyle?, section: SectionStyle?): TrackStyle =
|
|
48
37
|
TrackStyle(
|
|
49
|
-
//
|
|
50
|
-
//
|
|
38
|
+
// A track's display describes the page it opens and a section's describes its children's
|
|
39
|
+
// layout; neither is this item's own layout, so display never inherits onto an item.
|
|
51
40
|
display = null,
|
|
52
41
|
artworkRendering = track?.artworkRendering ?: section?.artworkRendering,
|
|
53
42
|
imageShape = track?.imageShape ?: section?.imageShape,
|
|
54
|
-
//
|
|
55
|
-
//
|
|
43
|
+
// "none" resolves like any other value; the renderer, not the resolver, reads it as no
|
|
44
|
+
// accessory.
|
|
56
45
|
accessorySymbol = track?.accessorySymbol ?: section?.accessorySymbol,
|
|
57
46
|
cardTint = track?.cardTint ?: section?.cardTint,
|
|
58
47
|
cardImage = track?.cardImage ?: section?.cardImage,
|
|
@@ -6,23 +6,13 @@ import com.margelo.nitro.core.Promise
|
|
|
6
6
|
import timber.log.Timber
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* If the handler is present, awaits it and returns [intercepted]. Otherwise runs [default].
|
|
12
|
-
*
|
|
13
|
-
* Nitro wraps value-returning JS callbacks in Promise<T> for thread safety, so a JS callback
|
|
14
|
-
* returning Promise<void> becomes Promise<Promise<Unit>> on the native side. Both layers must be
|
|
15
|
-
* awaited to properly wait for the JS work to complete.
|
|
16
|
-
*
|
|
17
|
-
* @param handler The handleTrackLoad callback from NativeBrowserConfiguration, or null
|
|
18
|
-
* @param track The track being loaded
|
|
19
|
-
* @param queue The resolved queue of tracks
|
|
20
|
-
* @param startIndex The index of the track in the queue
|
|
21
|
-
* @param intercepted Value to return when the handler is present and invoked
|
|
22
|
-
* @param defaultBehavior Value to return when no handler is configured
|
|
23
|
-
* @return Result of [intercepted] if handler was invoked, result of [defaultBehavior] otherwise
|
|
9
|
+
* Runs [defaultBehavior] when no [handler] is configured. Otherwise awaits the handler and runs
|
|
10
|
+
* [intercepted], even when the handler throws or rejects (the failure is logged, not rethrown).
|
|
24
11
|
*/
|
|
25
12
|
suspend fun <T> handleTrackLoad(
|
|
13
|
+
// Nitro wraps a value-returning JS callback in a Promise, so a JS callback returning
|
|
14
|
+
// Promise<void> arrives as Promise<Promise<Unit>>; both layers must be awaited for the JS work
|
|
15
|
+
// to finish.
|
|
26
16
|
handler: ((event: TrackLoadEvent) -> Promise<Promise<Unit>>)?,
|
|
27
17
|
track: Track,
|
|
28
18
|
queue: Array<Track>,
|
|
@@ -2,10 +2,12 @@ package com.audiobrowser.extension
|
|
|
2
2
|
|
|
3
3
|
class NumberExt {
|
|
4
4
|
companion object {
|
|
5
|
+
/** Reads the receiver as milliseconds. */
|
|
5
6
|
fun Number.toSeconds(): Double {
|
|
6
7
|
return this.toDouble() / 1000
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
/** Reads the receiver as seconds; truncates toward zero. */
|
|
9
11
|
fun Number.toMilliseconds(): Long {
|
|
10
12
|
return (this.toDouble() * 1000).toLong()
|
|
11
13
|
}
|
|
@@ -5,10 +5,8 @@ import com.margelo.nitro.audiobrowser.Track
|
|
|
5
5
|
import com.margelo.nitro.audiobrowser.TrackStyle
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* The Track
|
|
9
|
-
*
|
|
10
|
-
* share their field set — used to funnel ResolvedTracks through the single Track→MediaItem
|
|
11
|
-
* conversion in TrackFactory.
|
|
8
|
+
* The Track fields of a ResolvedTrack; the page-only fields (`sections`, `children`,
|
|
9
|
+
* `carPlaySiriListButton`) drop.
|
|
12
10
|
*/
|
|
13
11
|
fun ResolvedTrack.toTrack(): Track =
|
|
14
12
|
Track(
|
|
@@ -26,10 +24,8 @@ fun ResolvedTrack.toTrack(): Track =
|
|
|
26
24
|
description = description,
|
|
27
25
|
genre = genre,
|
|
28
26
|
duration = duration,
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
// Nitro flattens the spec's `extends`, making this narrowing a hand-written
|
|
32
|
-
// field list rather than an upcast (ADR 0011).
|
|
27
|
+
// SectionStyle narrows to TrackStyle by hand, dropping the page-wide `gridWrap`: Nitro
|
|
28
|
+
// flattens the spec's `extends`, so there is no upcast (ADR 0011).
|
|
33
29
|
style =
|
|
34
30
|
style?.let {
|
|
35
31
|
TrackStyle(
|
|
@@ -4,12 +4,10 @@ import com.audiobrowser.util.BrowserPathHelper
|
|
|
4
4
|
import com.margelo.nitro.audiobrowser.Track
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The queue
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* returns -1, and the caller falls through to expansion, which re-scopes the queue to the tapped
|
|
12
|
-
* section (ADR 0009).
|
|
7
|
+
* The queue index of the tapped track, for skipping in place, or -1. An exact path match wins,
|
|
8
|
+
* since the path's `__index` tells apart copies of the same identity. Only an index-less path falls
|
|
9
|
+
* back to matching [trackId]; an index-stamped path with no exact match returns -1, so the caller
|
|
10
|
+
* re-expands the queue to the tapped section (ADR 0009).
|
|
13
11
|
*/
|
|
14
12
|
fun Array<Track>.indexOfTappedTrack(contextualPath: String, trackId: String?): Int {
|
|
15
13
|
val index = indexOfFirst { it.path == contextualPath }
|
|
@@ -3,13 +3,9 @@ package com.audiobrowser.extension
|
|
|
3
3
|
import com.margelo.nitro.audiobrowser.Track
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `
|
|
9
|
-
*
|
|
10
|
-
* This is THE comparison rule for favorites matching, section scoping, skip-in-place, the car
|
|
11
|
-
* now-playing row indicator, and the contextual `__trackId` — see ADR 0008. Mirrors the TS
|
|
12
|
-
* `trackIdentity` helper.
|
|
6
|
+
* The key every comparison of tracks uses: `id` when non-blank, else `src`. Null for a
|
|
7
|
+
* browsable-only track (neither), which is addressed by `path` instead. Must match the TS
|
|
8
|
+
* `getTrackIdentity` helper — see ADR 0008.
|
|
13
9
|
*/
|
|
14
10
|
val Track.identity: String?
|
|
15
11
|
get() = id?.takeUnless { it.isBlank() } ?: src
|
|
@@ -29,14 +29,10 @@ class HttpClient {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* layer and every response body, so the interceptor is not installed in release at all: `BODY`
|
|
37
|
-
* also buffers and stringifies each response whether or not anything reads the log.
|
|
38
|
-
*
|
|
39
|
-
* The redactions apply in debug too. Logcat is shared in bug reports and screen shares.
|
|
32
|
+
* Debug builds only: Timber is an `api` dependency, so these lines reach the host app's trees
|
|
33
|
+
* (crash-reporter breadcrumbs included), and `BODY` buffers every response whether or not
|
|
34
|
+
* anything logs it. The credential headers below are redacted even in debug, as logcat ends up in
|
|
35
|
+
* bug reports; add any new one to the list.
|
|
40
36
|
*/
|
|
41
37
|
private fun loggingInterceptor() =
|
|
42
38
|
HttpLoggingInterceptor { message -> Timber.d(message) }
|
|
@@ -69,13 +65,14 @@ class HttpClient {
|
|
|
69
65
|
val code: Int,
|
|
70
66
|
val body: String,
|
|
71
67
|
val headers: Map<String, String>,
|
|
72
|
-
/** HTTP reason phrase
|
|
68
|
+
/** HTTP reason phrase, e.g. "Not Found"; OkHttp leaves it empty over HTTP/2. */
|
|
73
69
|
val message: String,
|
|
74
70
|
) {
|
|
75
71
|
val isSuccessful: Boolean
|
|
76
72
|
get() = code in 200..299
|
|
77
73
|
}
|
|
78
74
|
|
|
75
|
+
/** A non-2xx response is a success; check [HttpResponse.isSuccessful]. */
|
|
79
76
|
suspend fun request(httpRequest: HttpRequest): Result<HttpResponse> =
|
|
80
77
|
withContext(Dispatchers.IO) {
|
|
81
78
|
try {
|
|
@@ -87,21 +84,18 @@ class HttpClient {
|
|
|
87
84
|
|
|
88
85
|
val requestBuilder = Request.Builder().url(url)
|
|
89
86
|
|
|
90
|
-
// Add headers
|
|
91
87
|
val headers =
|
|
92
88
|
Headers.Builder()
|
|
93
89
|
.apply {
|
|
94
90
|
httpRequest.headers?.forEach { (name, value) -> add(name, value) }
|
|
95
|
-
// Set User-Agent (userAgent parameter takes precedence over headers)
|
|
96
91
|
add("User-Agent", httpRequest.userAgent)
|
|
97
92
|
}
|
|
98
93
|
.build()
|
|
99
94
|
requestBuilder.headers(headers)
|
|
100
95
|
|
|
101
|
-
// Add body for non-GET requests
|
|
102
96
|
when (httpRequest.method.uppercase()) {
|
|
103
97
|
"GET" -> {
|
|
104
|
-
|
|
98
|
+
// Request.Builder defaults to GET.
|
|
105
99
|
}
|
|
106
100
|
"POST",
|
|
107
101
|
"PUT",
|
|
@@ -144,6 +138,7 @@ class HttpClient {
|
|
|
144
138
|
}
|
|
145
139
|
}
|
|
146
140
|
|
|
141
|
+
/** Fails with [HttpException] on a non-2xx response. */
|
|
147
142
|
suspend inline fun <reified T> requestJson(httpRequest: HttpRequest): Result<T> {
|
|
148
143
|
return request(httpRequest).mapCatching { response ->
|
|
149
144
|
if (!response.isSuccessful) {
|
|
@@ -153,6 +148,7 @@ class HttpClient {
|
|
|
153
148
|
}
|
|
154
149
|
}
|
|
155
150
|
|
|
151
|
+
/** Fails with [HttpException] on a non-2xx response. */
|
|
156
152
|
suspend fun requestJsonElement(httpRequest: HttpRequest): Result<JsonElement> {
|
|
157
153
|
return request(httpRequest).mapCatching { response ->
|
|
158
154
|
if (!response.isSuccessful) {
|
|
@@ -162,15 +158,11 @@ class HttpClient {
|
|
|
162
158
|
}
|
|
163
159
|
}
|
|
164
160
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
/** HTTP reason phrase (e.g., "Not Found", "Service Unavailable") */
|
|
169
|
-
val reasonPhrase: String,
|
|
170
|
-
) : Exception(formatMessage(code, responseBody, reasonPhrase)) {
|
|
161
|
+
/** Its message is the JSON body's `error` field when there is one, else [reasonPhrase]. */
|
|
162
|
+
class HttpException(val code: Int, val responseBody: String, val reasonPhrase: String) :
|
|
163
|
+
Exception(formatMessage(code, responseBody, reasonPhrase)) {
|
|
171
164
|
companion object {
|
|
172
165
|
private fun formatMessage(code: Int, responseBody: String, reasonPhrase: String): String {
|
|
173
|
-
// Try to extract error message from JSON response: { "error": "message" }
|
|
174
166
|
try {
|
|
175
167
|
val json = org.json.JSONObject(responseBody)
|
|
176
168
|
val errorMessage = json.optString("error", null)
|
|
@@ -178,9 +170,8 @@ class HttpClient {
|
|
|
178
170
|
return errorMessage
|
|
179
171
|
}
|
|
180
172
|
} catch (_: Exception) {
|
|
181
|
-
// Not
|
|
173
|
+
// Not JSON: fall back to the reason phrase.
|
|
182
174
|
}
|
|
183
|
-
// Fall back to HTTP reason phrase
|
|
184
175
|
return reasonPhrase
|
|
185
176
|
}
|
|
186
177
|
}
|
|
@@ -16,8 +16,6 @@ object RequestConfigBuilder {
|
|
|
16
16
|
|
|
17
17
|
suspend fun buildHttpRequest(config: RequestConfig): HttpClient.HttpRequest =
|
|
18
18
|
withContext(Dispatchers.Default) {
|
|
19
|
-
|
|
20
|
-
// Build final URL with query parameters
|
|
21
19
|
val url = buildUrl(config)
|
|
22
20
|
|
|
23
21
|
HttpClient.HttpRequest(
|
|
@@ -30,6 +28,9 @@ object RequestConfigBuilder {
|
|
|
30
28
|
)
|
|
31
29
|
}
|
|
32
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Every non-null field of [override] wins, `path` included; headers and query merge key by key.
|
|
33
|
+
*/
|
|
33
34
|
fun mergeConfig(base: RequestConfig, override: RequestConfig): RequestConfig {
|
|
34
35
|
return RequestConfig(
|
|
35
36
|
path = override.path ?: base.path,
|
|
@@ -43,12 +44,7 @@ object RequestConfigBuilder {
|
|
|
43
44
|
)
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
/**
|
|
47
|
-
* Run-both resolve composition: the async-resolved config first, then the sync-resolved merged
|
|
48
|
-
* over it (sync winning). Returns null when neither produced a config. Extracted so the merge
|
|
49
|
-
* ordering is unit-testable without Nitro callbacks; used by [applyMediaResolve] and the artwork
|
|
50
|
-
* resolve in BrowserUrlResolution.
|
|
51
|
-
*/
|
|
47
|
+
/** Merges the sync-resolved config over the async-resolved one; null when both are null. */
|
|
52
48
|
fun composeResolved(asyncResolved: RequestConfig?, syncResolved: RequestConfig?): RequestConfig? {
|
|
53
49
|
return when {
|
|
54
50
|
asyncResolved == null -> syncResolved
|
|
@@ -58,18 +54,14 @@ object RequestConfigBuilder {
|
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* async callback hands a `Promise` downstream — the original "empty config" bug), so it lives in
|
|
64
|
-
* exactly one place. Pairs with [awaitSyncConfig].
|
|
57
|
+
* An async config callback lowers to `Promise<Promise<RequestConfig>>` (the bridge hop, then the
|
|
58
|
+
* JS promise); awaiting it once hands a Promise downstream as the config.
|
|
65
59
|
*/
|
|
66
60
|
suspend fun awaitAsyncConfig(promise: Promise<Promise<RequestConfig>>): RequestConfig =
|
|
67
61
|
promise.await().await()
|
|
68
62
|
|
|
69
|
-
/** Awaits a **sync** config callback (`Promise<RequestConfig>` — a single await). */
|
|
70
63
|
suspend fun awaitSyncConfig(promise: Promise<RequestConfig>): RequestConfig = promise.await()
|
|
71
64
|
|
|
72
|
-
/** Rebuilds a [MediaRequestConfig] with [c]'s request fields, preserving callbacks. */
|
|
73
65
|
private fun MediaRequestConfig.withRequestFields(c: RequestConfig) =
|
|
74
66
|
MediaRequestConfig(
|
|
75
67
|
resolve = resolve,
|
|
@@ -94,11 +86,10 @@ object RequestConfigBuilder {
|
|
|
94
86
|
}
|
|
95
87
|
|
|
96
88
|
/**
|
|
97
|
-
* Request-Config Layer
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* thrown transform falls back to the base.
|
|
89
|
+
* Applies [override] as a Request-Config Layer (GLOSSARY.md): its transforms, async then sync,
|
|
90
|
+
* replace the config and its static fields are then ignored; without one, its static fields merge
|
|
91
|
+
* over [base] except `path`, which stays the base's. Mirrors iOS `applyLayer`. A transform that
|
|
92
|
+
* throws yields [base].
|
|
102
93
|
*/
|
|
103
94
|
suspend fun mergeConfig(
|
|
104
95
|
base: RequestConfig,
|
|
@@ -109,8 +100,6 @@ object RequestConfigBuilder {
|
|
|
109
100
|
return mergeConfig(base, toRequestConfig(override)).copy(path = base.path)
|
|
110
101
|
}
|
|
111
102
|
return try {
|
|
112
|
-
// Async first, then sync (each replaces the running config). The bridge await
|
|
113
|
-
// depth is centralised in awaitAsync/SyncConfig.
|
|
114
103
|
var result = base
|
|
115
104
|
override.transform?.let { result = awaitAsyncConfig(it.invoke(result, routeParams)) }
|
|
116
105
|
override.transformSync?.let { result = awaitSyncConfig(it.invoke(result, routeParams)) }
|
|
@@ -122,9 +111,8 @@ object RequestConfigBuilder {
|
|
|
122
111
|
}
|
|
123
112
|
|
|
124
113
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* layer semantics live in one place.
|
|
114
|
+
* The layer rule of the [TransformableRequestConfig] overload, keeping [override]'s resolve
|
|
115
|
+
* callbacks.
|
|
128
116
|
*/
|
|
129
117
|
suspend fun mergeConfig(
|
|
130
118
|
base: RequestConfig,
|
|
@@ -148,20 +136,14 @@ object RequestConfigBuilder {
|
|
|
148
136
|
)
|
|
149
137
|
|
|
150
138
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* User-Agent) — and returns the config whose fields win.
|
|
155
|
-
*
|
|
156
|
-
* No-op when the media config has no `resolve` callback (so the request/media layers stand). The
|
|
157
|
-
* callback may return its config synchronously (variant `first`) or via a Promise (`second`).
|
|
158
|
-
* Mirrors iOS resolveMediaTrackConfig + applyMediaResolveLayer.
|
|
139
|
+
* Merges the config `media.resolve(track)` and `resolveSync(track)` return over [layered], as the
|
|
140
|
+
* last layer: its non-null fields win, `path` included. Returns [layered] unchanged when there is
|
|
141
|
+
* no resolve callback or it throws. Mirrors iOS `resolveMediaTrackConfig`.
|
|
159
142
|
*/
|
|
160
143
|
suspend fun applyMediaResolve(layered: MediaRequestConfig, track: Track): MediaRequestConfig {
|
|
161
144
|
if (layered.resolve == null && layered.resolveSync == null) return layered
|
|
162
145
|
val resolved: RequestConfig =
|
|
163
146
|
try {
|
|
164
|
-
// Async first, then sync (merged, sync winning) — via the tested helper.
|
|
165
147
|
val asyncResolved = layered.resolve?.let { awaitAsyncConfig(it.invoke(track)) }
|
|
166
148
|
val syncResolved = layered.resolveSync?.let { awaitSyncConfig(it.invoke(track)) }
|
|
167
149
|
composeResolved(asyncResolved, syncResolved) ?: return layered
|
|
@@ -169,7 +151,6 @@ object RequestConfigBuilder {
|
|
|
169
151
|
Timber.e(e, "Failed to apply media.resolve, using layered config")
|
|
170
152
|
return layered
|
|
171
153
|
}
|
|
172
|
-
// Resolve wins: merge it over the layered config (override-wins on every field).
|
|
173
154
|
val merged = mergeConfig(toRequestConfig(layered), resolved)
|
|
174
155
|
return layered.withRequestFields(merged)
|
|
175
156
|
}
|
|
@@ -220,7 +201,7 @@ object RequestConfigBuilder {
|
|
|
220
201
|
return when {
|
|
221
202
|
base == null -> override
|
|
222
203
|
override == null -> base
|
|
223
|
-
else -> base + override
|
|
204
|
+
else -> base + override
|
|
224
205
|
}
|
|
225
206
|
}
|
|
226
207
|
|
|
@@ -231,7 +212,7 @@ object RequestConfigBuilder {
|
|
|
231
212
|
return when {
|
|
232
213
|
base == null -> override
|
|
233
214
|
override == null -> base
|
|
234
|
-
else -> base + override
|
|
215
|
+
else -> base + override
|
|
235
216
|
}
|
|
236
217
|
}
|
|
237
218
|
|
|
@@ -239,10 +220,8 @@ object RequestConfigBuilder {
|
|
|
239
220
|
val path = config.path ?: ""
|
|
240
221
|
val baseUrl = config.baseUrl
|
|
241
222
|
|
|
242
|
-
// Use BrowserPathHelper for consistent URL building
|
|
243
223
|
val url = BrowserPathHelper.buildUrl(baseUrl, path)
|
|
244
224
|
|
|
245
|
-
// Add query parameters if any
|
|
246
225
|
val queryString =
|
|
247
226
|
config.query?.let { query ->
|
|
248
227
|
if (query.isNotEmpty()) {
|
|
@@ -2,14 +2,13 @@ package com.audiobrowser.model
|
|
|
2
2
|
|
|
3
3
|
import java.nio.charset.Charset
|
|
4
4
|
|
|
5
|
-
/** Re-decodes an ICY `StreamTitle` with the charset the track declares. */
|
|
6
5
|
internal object IcyTitle {
|
|
7
6
|
/**
|
|
8
|
-
* [title] re-decoded
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* [title] re-decoded with [charset] when it is Latin-1 shaped: every char at or below U+00FF and
|
|
8
|
+
* at least one at or above U+0080. media3 yields that shape both when it falls back to ISO-8859-1
|
|
9
|
+
* for bytes that are not UTF-8 and when a station UTF-8-encoded its legacy bytes; ISO-8859-1 is
|
|
10
|
+
* lossless, so both re-decode. Returns [title] unchanged when it has another shape, is pure
|
|
11
|
+
* ASCII, or the runtime has no [charset].
|
|
13
12
|
*/
|
|
14
13
|
fun redecode(title: String, charset: String): String {
|
|
15
14
|
var high = false
|
|
@@ -14,17 +14,15 @@ data class PlaybackMetadata(
|
|
|
14
14
|
) {
|
|
15
15
|
companion object {
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* The ICY title when [metadata] holds one, otherwise what media3 maps from the other entries
|
|
18
|
+
* (ID3, Vorbis, QuickTime…); null when neither yields a field. [icyCharset] re-decodes ICY
|
|
19
|
+
* titles media3 decoded as Latin-1 ([IcyTitle.redecode]); it never touches other metadata.
|
|
20
20
|
*/
|
|
21
21
|
fun from(metadata: Metadata, icyCharset: String? = null): PlaybackMetadata? {
|
|
22
|
-
// Try ICY first (streaming-specific)
|
|
23
22
|
fromIcy(metadata, icyCharset)?.let {
|
|
24
23
|
return it
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
// Use Media3's unified approach for ID3, Vorbis, QuickTime, etc.
|
|
28
26
|
val builder = MediaMetadata.Builder()
|
|
29
27
|
for (i in 0 until metadata.length()) {
|
|
30
28
|
metadata[i].populateMediaMetadata(builder)
|
|
@@ -32,7 +30,7 @@ data class PlaybackMetadata(
|
|
|
32
30
|
return fromMediaMetadata(builder.build())
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
// ICY (Shoutcast / Icecast): https://cast.readme.io/docs/icy
|
|
36
34
|
private fun fromIcy(metadata: Metadata, icyCharset: String?): PlaybackMetadata? {
|
|
37
35
|
for (i in 0 until metadata.length()) {
|
|
38
36
|
when (val entry = metadata[i]) {
|
|
@@ -49,17 +47,14 @@ data class PlaybackMetadata(
|
|
|
49
47
|
return null
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
/** Converts Media3's unified MediaMetadata to PlaybackMetadata. */
|
|
53
50
|
private fun fromMediaMetadata(mediaMetadata: MediaMetadata): PlaybackMetadata? {
|
|
54
51
|
val title = mediaMetadata.title?.toString()
|
|
55
52
|
val artist = mediaMetadata.artist?.toString()
|
|
56
53
|
val album = mediaMetadata.albumTitle?.toString()
|
|
57
54
|
val genre = mediaMetadata.genre?.toString()
|
|
58
55
|
|
|
59
|
-
// Use recordingYear first (more specific), fall back to releaseYear
|
|
60
56
|
val date = (mediaMetadata.recordingYear ?: mediaMetadata.releaseYear)?.toString()
|
|
61
57
|
|
|
62
|
-
// Return null if no meaningful data
|
|
63
58
|
if (title == null && artist == null && album == null && genre == null && date == null) {
|
|
64
59
|
return null
|
|
65
60
|
}
|