react-native-audio-browser 0.2.0-next.53 → 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/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/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
|
#if !canImport(NitroModules)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/// native job can see both files at once. Declaring fewer properties than the
|
|
12
|
-
/// real type is fine and deliberate; spelling one differently is what that
|
|
13
|
-
/// test catches. Conformances and default values are still on you.
|
|
2
|
+
// Stand-ins for the NitroModules types, compiled only in SwiftPM test builds.
|
|
3
|
+
//
|
|
4
|
+
// They declare `Equatable` for tests; the generated types do not. Shared `ios/` sources
|
|
5
|
+
// must not rely on a conformance that exists only here: `swift test` passes and the app
|
|
6
|
+
// build breaks.
|
|
7
|
+
//
|
|
8
|
+
// src/nitro-stub-drift.test.ts (JS CI) checks property names and types against
|
|
9
|
+
// nitrogen/generated/ios/swift. Declaring fewer properties than the real type is fine;
|
|
10
|
+
// conformances and default values are not checked.
|
|
14
11
|
|
|
15
12
|
struct ArtworkVariants: Equatable {
|
|
16
13
|
var light: String
|
|
@@ -28,8 +25,8 @@
|
|
|
28
25
|
var query: [String: String]?
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
// Every property of the generated type, in its init's order, so the shared conversions in
|
|
29
|
+
// JsonModels compile against both.
|
|
33
30
|
struct Track: Equatable {
|
|
34
31
|
var id: String?
|
|
35
32
|
var path: String?
|
|
@@ -252,8 +249,6 @@
|
|
|
252
249
|
}
|
|
253
250
|
}
|
|
254
251
|
|
|
255
|
-
// Mirrors the generated extension (nitrogen emits `stringValue` beside
|
|
256
|
-
// `init?(fromString:)` for every string-backed enum).
|
|
257
252
|
var stringValue: String {
|
|
258
253
|
switch self {
|
|
259
254
|
case .plain: "plain"
|
|
@@ -286,10 +281,9 @@
|
|
|
286
281
|
var cardImage: CardImage?
|
|
287
282
|
}
|
|
288
283
|
|
|
289
|
-
// Member order matches the generated init
|
|
290
|
-
//
|
|
291
|
-
//
|
|
292
|
-
// `swift test` passes while the app build breaks on argument order.
|
|
284
|
+
// Member order matches the generated init, own properties before inherited ones (Nitro
|
|
285
|
+
// flattens `extends` own-props-first): a different order still passes `swift test` but
|
|
286
|
+
// breaks the app build.
|
|
293
287
|
struct SectionStyle: Equatable {
|
|
294
288
|
var gridWrap: Bool?
|
|
295
289
|
var gridTile: GridTile?
|
|
@@ -425,8 +419,7 @@
|
|
|
425
419
|
|
|
426
420
|
// MARK: - Playback Event Types (used by Player)
|
|
427
421
|
|
|
428
|
-
|
|
429
|
-
/// exposes from a public property.
|
|
422
|
+
// Public like the generated enum, which `TrackPlayerError` exposes from a public property.
|
|
430
423
|
public enum PlaybackErrorKind {
|
|
431
424
|
case offline
|
|
432
425
|
case unreachable
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import NitroModules
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Update options for the player that can be changed at runtime.
|
|
6
|
-
* These options control player behavior and capabilities that can be modified during playback.
|
|
7
|
-
*/
|
|
8
4
|
class PlayerUpdateOptions {
|
|
9
5
|
// MARK: - Core Properties
|
|
10
6
|
|
|
11
|
-
/// Jump intervals
|
|
12
7
|
var forwardJumpInterval: Double = 15.0
|
|
13
8
|
var backwardJumpInterval: Double = 15.0
|
|
14
9
|
var progressUpdateEventInterval: Double?
|
|
15
|
-
|
|
10
|
+
// Set through `setPlaybackIntervalEnabled`; neither `update(from:)` nor `toOptions()` touches it.
|
|
16
11
|
var playbackIntervalEnabled = false
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
// An unset capability counts as enabled (`remoteCommands`), except favorite, so the jump
|
|
14
|
+
// commands start explicitly disabled.
|
|
20
15
|
var capabilities: PlayerCapabilities = .init(
|
|
21
16
|
play: nil, pause: nil, stop: nil, seekTo: nil,
|
|
22
17
|
skipToNext: nil, skipToPrevious: nil,
|
|
@@ -25,16 +20,12 @@ class PlayerUpdateOptions {
|
|
|
25
20
|
shuffleMode: nil, repeatMode: nil, playbackRate: nil,
|
|
26
21
|
)
|
|
27
22
|
|
|
28
|
-
/// Supported playback rates for the playback-rate capability
|
|
29
23
|
var playbackRates: [Double] = [0.5, 1.0, 1.5, 2.0]
|
|
30
24
|
|
|
31
|
-
/// Enable the "Up Next" button on the CarPlay Now Playing screen
|
|
32
25
|
var carPlayUpNextButton: Bool = true
|
|
33
26
|
|
|
34
|
-
/// Custom buttons for the CarPlay Now Playing screen
|
|
35
27
|
var carPlayNowPlayingButtons: [CarPlayNowPlayingButton] = []
|
|
36
28
|
|
|
37
|
-
/// Where the now-playing indicator draws on CarPlay list rows
|
|
38
29
|
var carPlayPlayingIndicatorLocation: CarPlayPlayingIndicatorLocation = .leading
|
|
39
30
|
|
|
40
31
|
// MARK: - Initialization
|
|
@@ -43,32 +34,28 @@ class PlayerUpdateOptions {
|
|
|
43
34
|
|
|
44
35
|
// MARK: - Update from Nitro Options
|
|
45
36
|
|
|
46
|
-
///
|
|
37
|
+
/// Applies only the fields `options` sets. Capabilities merge field by field, so an unset
|
|
38
|
+
/// capability keeps its value; a null progress interval turns progress events off.
|
|
47
39
|
func update(from options: NativeUpdateOptions) {
|
|
48
|
-
// Update jump intervals
|
|
49
40
|
if let interval = options.forwardJumpInterval {
|
|
50
41
|
forwardJumpInterval = interval
|
|
51
42
|
}
|
|
52
43
|
if let interval = options.backwardJumpInterval {
|
|
53
44
|
backwardJumpInterval = interval
|
|
54
45
|
}
|
|
55
|
-
// progressUpdateEventInterval is a Variant_NullType_Double - extract the Double
|
|
56
46
|
if let interval = options.progressUpdateEventInterval {
|
|
57
47
|
switch interval {
|
|
58
48
|
case .first:
|
|
59
|
-
// null - disable progress updates
|
|
60
49
|
progressUpdateEventInterval = nil
|
|
61
50
|
case let .second(value):
|
|
62
51
|
progressUpdateEventInterval = value
|
|
63
52
|
}
|
|
64
53
|
}
|
|
65
54
|
|
|
66
|
-
// Update capabilities - merge incoming with existing, only explicitly set values override
|
|
67
55
|
if let caps = options.capabilities {
|
|
68
56
|
capabilities = mergeCapabilities(existing: capabilities, incoming: caps)
|
|
69
57
|
}
|
|
70
58
|
|
|
71
|
-
// Update iOS player-UI options (nested under `ios` on the wire)
|
|
72
59
|
if let ios = options.ios {
|
|
73
60
|
if let rates = ios.playbackRates {
|
|
74
61
|
playbackRates = rates
|
|
@@ -85,9 +72,8 @@ class PlayerUpdateOptions {
|
|
|
85
72
|
}
|
|
86
73
|
}
|
|
87
74
|
|
|
88
|
-
/// The
|
|
75
|
+
/// The options in their wire shape, as `getOptions` and `onOptionsChanged` report them.
|
|
89
76
|
func toOptions() -> Options {
|
|
90
|
-
// Convert Double? to Variant_NullType_Double?
|
|
91
77
|
let progressInterval: Variant_NullType_Double? = progressUpdateEventInterval.map { .second($0) }
|
|
92
78
|
|
|
93
79
|
return Options(
|
|
@@ -105,7 +91,6 @@ class PlayerUpdateOptions {
|
|
|
105
91
|
)
|
|
106
92
|
}
|
|
107
93
|
|
|
108
|
-
/// Merge incoming capabilities with existing - only explicitly set values override
|
|
109
94
|
private func mergeCapabilities(existing: PlayerCapabilities, incoming: PlayerCapabilities) -> PlayerCapabilities {
|
|
110
95
|
PlayerCapabilities(
|
|
111
96
|
play: incoming.play ?? existing.play,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
|
|
3
|
-
/// A system remote command (lock screen, Control Center, CarPlay, headset).
|
|
4
|
-
///
|
|
3
|
+
/// A system remote command (lock screen, Control Center, CarPlay, headset). Skip intervals and
|
|
4
|
+
/// playback rates are passed to `RemoteCommandController.enable` beside the commands.
|
|
5
5
|
enum RemoteCommand: CaseIterable, Hashable {
|
|
6
6
|
case play
|
|
7
7
|
case pause
|
|
@@ -8,9 +8,8 @@ public enum TrackPlayerError: Error {
|
|
|
8
8
|
case failedToLoadKeyValue
|
|
9
9
|
case invalidSourceUrl(String)
|
|
10
10
|
case notConnectedToInternet
|
|
11
|
-
/// DNS, connect, timeout or a dropped connection
|
|
11
|
+
/// A transport failure: DNS, connect, TLS, timeout, or a dropped connection, which can come mid-stream after audio has played.
|
|
12
12
|
case hostUnreachable
|
|
13
|
-
/// The server answered with a non-2xx status.
|
|
14
13
|
case httpStatus(Int)
|
|
15
14
|
case playbackFailed
|
|
16
15
|
case trackWasUnplayable
|
|
@@ -21,7 +20,6 @@ public enum TrackPlayerError: Error {
|
|
|
21
20
|
case noCurrentItem
|
|
22
21
|
case invalidIndex(index: Int, message: String)
|
|
23
22
|
case empty
|
|
24
|
-
/// A track with neither `src` nor `path`, which no queue can hold.
|
|
25
23
|
case invalidTrack(title: String)
|
|
26
24
|
}
|
|
27
25
|
}
|
|
@@ -67,8 +65,7 @@ extension TrackPlayerError.QueueError: LocalizedError {
|
|
|
67
65
|
// MARK: - Cross-platform Classification
|
|
68
66
|
|
|
69
67
|
public extension TrackPlayerError.PlaybackError {
|
|
70
|
-
///
|
|
71
|
-
/// on `kind`; this is what they log.
|
|
68
|
+
/// For diagnostics and telemetry only; consumers branch on `kind`.
|
|
72
69
|
var code: String {
|
|
73
70
|
switch self {
|
|
74
71
|
case .failedToLoadKeyValue: "failed-to-load"
|
|
@@ -82,23 +79,19 @@ public extension TrackPlayerError.PlaybackError {
|
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
81
|
|
|
85
|
-
///
|
|
86
|
-
/// from its ExoPlayer codes, so app-side copy can switch on this alone.
|
|
82
|
+
/// Android maps its ExoPlayer errors onto the same kinds; keep the two in step.
|
|
87
83
|
var kind: PlaybackErrorKind {
|
|
88
84
|
switch self {
|
|
89
85
|
case .notConnectedToInternet: .offline
|
|
90
86
|
case .hostUnreachable: .unreachable
|
|
91
87
|
case let .httpStatus(status): TrackPlayerError.PlaybackError.kind(forHttpStatus: status)
|
|
92
|
-
//
|
|
93
|
-
// side — same outcome as an undecodable one.
|
|
88
|
+
// To the listener a missing or malformed URL is as broken as an undecodable stream.
|
|
94
89
|
case .invalidSourceUrl, .trackWasUnplayable: .unplayable
|
|
95
90
|
case .playbackStalled: .stalled
|
|
96
|
-
// Context fallbacks: the underlying error carried nothing we could classify.
|
|
97
91
|
case .failedToLoadKeyValue, .playbackFailed: .unknown
|
|
98
92
|
}
|
|
99
93
|
}
|
|
100
94
|
|
|
101
|
-
/// The HTTP status behind this error, when it came from a server response.
|
|
102
95
|
var statusCode: Int? {
|
|
103
96
|
if case let .httpStatus(status) = self { return status }
|
|
104
97
|
return nil
|
|
@@ -108,8 +101,7 @@ public extension TrackPlayerError.PlaybackError {
|
|
|
108
101
|
switch status {
|
|
109
102
|
case 404, 410: .notFound
|
|
110
103
|
case 500 ... 599: .serverError
|
|
111
|
-
//
|
|
112
|
-
// rate limit. All of them mean "you can't have this stream", not "retry".
|
|
104
|
+
// Auth, geo-blocking, rate limits: the stream is refused, not worth retrying.
|
|
113
105
|
case 400 ... 499: .rejected
|
|
114
106
|
default: .unknown
|
|
115
107
|
}
|
|
@@ -118,17 +110,12 @@ public extension TrackPlayerError.PlaybackError {
|
|
|
118
110
|
|
|
119
111
|
// MARK: - Nitro PlaybackError Conversion
|
|
120
112
|
|
|
121
|
-
// Internal, not public: the stub `PlaybackError` struct is internal, and every
|
|
122
|
-
// caller of this lives in the module.
|
|
123
113
|
extension TrackPlayerError.PlaybackError {
|
|
124
|
-
///
|
|
114
|
+
/// `retrying` marks an error the retry loop is still working on; a terminal
|
|
115
|
+
/// error carries nil, not false.
|
|
125
116
|
///
|
|
126
|
-
///
|
|
127
|
-
///
|
|
128
|
-
/// definition compiles in both worlds and the tests exercise the shipped
|
|
129
|
-
/// converter rather than a copy of it.
|
|
130
|
-
/// `retrying` marks an advisory error the retry loop is still working on
|
|
131
|
-
/// (surfaced with a non-terminal playback state); terminal errors leave it nil.
|
|
117
|
+
/// Not behind `#if canImport(NitroModules)`: the stub in `NitroTypeStubs` mirrors
|
|
118
|
+
/// the generated struct, so the tests exercise this converter.
|
|
132
119
|
func toNitroError(retrying: Bool = false) -> PlaybackError {
|
|
133
120
|
PlaybackError(
|
|
134
121
|
kind: kind,
|
|
@@ -3,31 +3,24 @@ import Foundation
|
|
|
3
3
|
@preconcurrency import MediaPlayer
|
|
4
4
|
import os.log
|
|
5
5
|
|
|
6
|
-
///
|
|
7
|
-
///
|
|
8
|
-
///
|
|
9
|
-
///
|
|
10
|
-
/// the player, so the per-second clock stays out of our code (it extrapolates the
|
|
11
|
-
/// scrubber). We supply what automatic publishing does not: metadata (title/artist/
|
|
12
|
-
/// artwork), attached to `AVPlayerItem.nowPlayingInfo` (the supported channel under
|
|
13
|
-
/// automatic publishing). An explicit `playbackState` would be dropped: iOS ignores it
|
|
14
|
-
/// without a private entitlement (ADR 0005).
|
|
6
|
+
/// Publishes now-playing metadata through an auto-publishing `MPNowPlayingSession` bound to the
|
|
7
|
+
/// linked AVPlayer. The session derives elapsed time, rate and duration from the player; this
|
|
8
|
+
/// supplies the rest (title, artist, artwork) on `AVPlayerItem.nowPlayingInfo`. There is no
|
|
9
|
+
/// `playbackState`: iOS drops it without a private entitlement (docs/adr/0005).
|
|
15
10
|
@MainActor
|
|
16
11
|
class NowPlayingInfoController {
|
|
17
12
|
private let logger = Logger(subsystem: "com.audiobrowser", category: "NowPlayingInfoController")
|
|
18
13
|
|
|
19
14
|
private var _info: [String: Any] = [:]
|
|
20
15
|
|
|
21
|
-
/// The session bound to the linked AVPlayer; held so it stays alive while publishing.
|
|
22
16
|
private var nowPlayingSession: MPNowPlayingSession?
|
|
23
17
|
|
|
24
|
-
/// The linked AVPlayer — metadata is attached to its current item.
|
|
25
18
|
private weak var linkedPlayer: AVPlayer?
|
|
26
19
|
|
|
27
20
|
required init() {}
|
|
28
21
|
|
|
29
|
-
/// Binds
|
|
30
|
-
///
|
|
22
|
+
/// Binds the player to a new auto-publishing session and returns that session's own remote
|
|
23
|
+
/// command center, which remote commands must now be enabled on.
|
|
31
24
|
func linkPlayer(_ player: AVPlayer) -> MPRemoteCommandCenter {
|
|
32
25
|
logger.notice("Linking AVPlayer to MPNowPlayingSession for automatic publishing")
|
|
33
26
|
|
|
@@ -44,14 +37,9 @@ class NowPlayingInfoController {
|
|
|
44
37
|
return session.remoteCommandCenter
|
|
45
38
|
}
|
|
46
39
|
|
|
47
|
-
/// Re-requests
|
|
48
|
-
///
|
|
49
|
-
///
|
|
50
|
-
/// system can decline the election at that point. Without a later re-request the
|
|
51
|
-
/// session stays unfeatured until actual audio output elects the app through the
|
|
52
|
-
/// system's own path — which never happens when the first-ever load fails (a cold
|
|
53
|
-
/// start onto a dead stream showed no now-playing surface at all). Call whenever
|
|
54
|
-
/// the audio session (re)activates; no-op while already active.
|
|
40
|
+
/// Re-requests activation of the linked session; no-op while it is active. Call whenever the
|
|
41
|
+
/// audio session (re)activates: `linkPlayer` runs before it is active, the system can decline
|
|
42
|
+
/// then, and if the first load fails no audio output ever elects the app instead.
|
|
55
43
|
func reactivateSessionIfNeeded() {
|
|
56
44
|
guard let session = nowPlayingSession, !session.isActive else { return }
|
|
57
45
|
logger.notice("MPNowPlayingSession inactive (canBecomeActive: \(session.canBecomeActive)) — re-requesting activation")
|
|
@@ -60,8 +48,8 @@ class NowPlayingInfoController {
|
|
|
60
48
|
}
|
|
61
49
|
}
|
|
62
50
|
|
|
63
|
-
///
|
|
64
|
-
///
|
|
51
|
+
/// Drops the session along with its command center. Remote commands never fall back to the
|
|
52
|
+
/// shared center, whose targets belong to the host app.
|
|
65
53
|
func unlinkPlayer() {
|
|
66
54
|
logger.info("Unlinking AVPlayer from MPNowPlayingSession")
|
|
67
55
|
|
|
@@ -70,18 +58,14 @@ class NowPlayingInfoController {
|
|
|
70
58
|
nowPlayingSession = nil
|
|
71
59
|
}
|
|
72
60
|
|
|
73
|
-
|
|
74
|
-
/// the system owns elapsed/duration/rate.
|
|
61
|
+
// The session derives these from the player; setting them too would fight it.
|
|
75
62
|
private static let autoPublishedKeys: Set<String> = [
|
|
76
63
|
MPNowPlayingInfoPropertyElapsedPlaybackTime,
|
|
77
64
|
MPMediaItemPropertyPlaybackDuration,
|
|
78
65
|
MPNowPlayingInfoPropertyPlaybackRate,
|
|
79
66
|
]
|
|
80
67
|
|
|
81
|
-
|
|
82
|
-
/// re-publishing unchanged metadata. Compares the comparable scalar types we
|
|
83
|
-
/// store (title/artist/album strings, isLiveStream); non-comparable values
|
|
84
|
-
/// (e.g. artwork) are treated as changed.
|
|
68
|
+
// Values of any other type (artwork) always count as changed.
|
|
85
69
|
private func valueUnchanged(_ key: String, _ newValue: Any?) -> Bool {
|
|
86
70
|
switch (_info[key], newValue) {
|
|
87
71
|
case (nil, nil): true
|
|
@@ -92,9 +76,9 @@ class NowPlayingInfoController {
|
|
|
92
76
|
}
|
|
93
77
|
}
|
|
94
78
|
|
|
95
|
-
/// Sets now-playing fields
|
|
96
|
-
///
|
|
97
|
-
///
|
|
79
|
+
/// Sets now-playing fields by their `MPMediaItemProperty*` / `MPNowPlayingInfoProperty*` keys
|
|
80
|
+
/// (nil removes one) and publishes if any changed. Elapsed time, duration and rate are ignored:
|
|
81
|
+
/// the session publishes those. Returns whether anything changed.
|
|
98
82
|
@discardableResult
|
|
99
83
|
func set(_ fields: [String: Any?]) -> Bool {
|
|
100
84
|
var changed = false
|
|
@@ -106,10 +90,9 @@ class NowPlayingInfoController {
|
|
|
106
90
|
return changed
|
|
107
91
|
}
|
|
108
92
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
/// intent and item creation; the item channel takes over via `prepareItem`.
|
|
93
|
+
// The item is the supported channel under automatic publishing. Before one exists (its URL
|
|
94
|
+
// still resolving) the info goes to the session's center, so the surface isn't blank
|
|
95
|
+
// meanwhile; `prepareItem` hands it to the item channel.
|
|
113
96
|
private func performUpdate() {
|
|
114
97
|
if let item = linkedPlayer?.currentItem {
|
|
115
98
|
item.nowPlayingInfo = _info
|
|
@@ -118,14 +101,12 @@ class NowPlayingInfoController {
|
|
|
118
101
|
}
|
|
119
102
|
}
|
|
120
103
|
|
|
121
|
-
///
|
|
122
|
-
/// session has
|
|
123
|
-
/// Call this before `replaceCurrentItem(with:)`.
|
|
104
|
+
/// Copies the current info onto an item. Call before `replaceCurrentItem(with:)`, so the
|
|
105
|
+
/// session has it from the item's first moment.
|
|
124
106
|
func prepareItem(_ item: AVPlayerItem) {
|
|
125
107
|
item.nowPlayingInfo = _info
|
|
126
108
|
}
|
|
127
109
|
|
|
128
|
-
/// Clears all Now Playing info.
|
|
129
110
|
func clear() {
|
|
130
111
|
_info = [:]
|
|
131
112
|
linkedPlayer?.currentItem?.nowPlayingInfo = nil
|
|
@@ -2,26 +2,21 @@ import AVFoundation
|
|
|
2
2
|
import Foundation
|
|
3
3
|
import os.log
|
|
4
4
|
|
|
5
|
-
///
|
|
5
|
+
/// Plays a fraction of a second of silence (zero samples) through the app's audio session.
|
|
6
6
|
///
|
|
7
|
-
/// iOS
|
|
8
|
-
///
|
|
9
|
-
///
|
|
10
|
-
/// `
|
|
11
|
-
///
|
|
12
|
-
///
|
|
13
|
-
/// renders and the failure line + transport controls have nowhere to appear.
|
|
14
|
-
/// Rendering one burst of silence satisfies the election rule; the session's
|
|
15
|
-
/// already-published info (station + failure line) then displays.
|
|
16
|
-
///
|
|
17
|
-
/// The samples are zeros: inaudible by construction, no volume tricks involved.
|
|
7
|
+
/// iOS puts an app on the now-playing surfaces (lock screen, Control Center, CarPlay) only once
|
|
8
|
+
/// its audio session renders output; published metadata alone never surfaces it, and
|
|
9
|
+
/// `MPNowPlayingInfoCenter.playbackState` is dropped without a private entitlement
|
|
10
|
+
/// (`com.apple.mediaremote.set-playback-state`). When the first load fails, nothing renders, so
|
|
11
|
+
/// the already-published info and transport controls never show. This burst wins the election
|
|
12
|
+
/// (docs/adr/0005).
|
|
18
13
|
@MainActor
|
|
19
14
|
final class SilentAudioPrimer {
|
|
20
15
|
private let logger = Logger(subsystem: "com.audiobrowser", category: "SilentAudioPrimer")
|
|
21
16
|
|
|
22
17
|
private static let duration: TimeInterval = 0.3
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
// Held until playback ends; a released AVAudioPlayer stops rendering.
|
|
25
20
|
private var player: AVAudioPlayer?
|
|
26
21
|
|
|
27
22
|
func prime() {
|
|
@@ -40,8 +35,7 @@ final class SilentAudioPrimer {
|
|
|
40
35
|
}
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
/// content is zeros, so fidelity is irrelevant.
|
|
38
|
+
// Mono 16-bit PCM WAV; 8 kHz keeps it a few KB, and zeros need no fidelity.
|
|
45
39
|
private static let silentWav: Data? = makeSilentWav()
|
|
46
40
|
|
|
47
41
|
private static func makeSilentWav() -> Data? {
|
|
@@ -58,7 +52,7 @@ final class SilentAudioPrimer {
|
|
|
58
52
|
append32(36 + dataSize)
|
|
59
53
|
append("WAVE")
|
|
60
54
|
append("fmt ")
|
|
61
|
-
append32(16) //
|
|
55
|
+
append32(16) // fmt chunk size
|
|
62
56
|
append16(1) // linear PCM
|
|
63
57
|
append16(1) // mono
|
|
64
58
|
append32(sampleRate)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
@preconcurrency import AVFoundation
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// Read only on the main actor: the metadata delegate is set to the main queue, and AVAsset's
|
|
4
|
+
// async loads hand their groups back to the @MainActor MediaLoader.
|
|
4
5
|
extension AVTimedMetadataGroup: @retroactive @unchecked Sendable {}
|
|
5
6
|
|
|
6
|
-
/// Observes one AVPlayerItem
|
|
7
|
-
///
|
|
8
|
-
///
|
|
9
|
-
///
|
|
7
|
+
/// Observes one AVPlayerItem until `invalidate()`: status, buffering, end-of-item and stall
|
|
8
|
+
/// notifications, and timed metadata. KVO and notifications arrive off the main thread; whatever
|
|
9
|
+
/// lands after `invalidate()` is dropped, so an old item's late failure never reaches the next
|
|
10
|
+
/// item's handlers.
|
|
10
11
|
@MainActor
|
|
11
12
|
final class ItemObserver: NSObject {
|
|
12
13
|
enum Event {
|
|
@@ -85,6 +86,7 @@ extension ItemObserver: AVPlayerItemMetadataOutputPushDelegate {
|
|
|
85
86
|
didOutputTimedMetadataGroups groups: [AVTimedMetadataGroup],
|
|
86
87
|
from _: AVPlayerItemTrack?,
|
|
87
88
|
) {
|
|
89
|
+
// Safe: init sets the delegate queue to .main.
|
|
88
90
|
MainActor.assumeIsolated { emit(.timedMetadata(groups)) }
|
|
89
91
|
}
|
|
90
92
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import AVFoundation
|
|
2
2
|
|
|
3
|
-
/// Observes one AVPlayer
|
|
4
|
-
///
|
|
5
|
-
///
|
|
3
|
+
/// Observes one AVPlayer until `invalidate()`: status, time-control status, and the moment audio
|
|
4
|
+
/// starts. A recreated player gets a new observer, so nothing a released player reports reaches
|
|
5
|
+
/// its successor.
|
|
6
6
|
@MainActor
|
|
7
7
|
final class PlayerObserver {
|
|
8
8
|
enum Event {
|
|
@@ -41,8 +41,8 @@ final class PlayerObserver {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/// Stops all delivery, including events already hopping to the main actor.
|
|
45
|
-
///
|
|
44
|
+
/// Stops all delivery, including events already hopping to the main actor. AVPlayer retains its
|
|
45
|
+
/// time observers, so one left registered outlives this observer (#96).
|
|
46
46
|
func invalidate() {
|
|
47
47
|
isActive = false
|
|
48
48
|
observations.removeAll()
|
package/ios/PlaybackEvent.swift
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
///
|
|
2
|
-
///
|
|
1
|
+
/// What happened to playback; `nextPlaybackState` decides the resulting state, and the call site
|
|
2
|
+
/// decides whether to fire the event at all.
|
|
3
3
|
enum PlaybackEvent {
|
|
4
4
|
case stopped
|
|
5
5
|
case trackLoading
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
///
|
|
2
|
-
///
|
|
1
|
+
/// Whether to re-issue `play()` for an AirPlay stall. Kept free of AVFoundation so it is
|
|
2
|
+
/// unit-testable off-device.
|
|
3
3
|
///
|
|
4
|
-
/// Over AirPlay, AVPlayer can
|
|
5
|
-
///
|
|
6
|
-
///
|
|
7
|
-
///
|
|
8
|
-
/// legitimate pause on the local route.
|
|
4
|
+
/// Over AirPlay, AVPlayer can go from `.waitingToPlayAtSpecifiedRate` (reason `.noItemToPlay`)
|
|
5
|
+
/// to `.paused` while the app still means to play, leaving playback silent with no error;
|
|
6
|
+
/// `play()` on exactly that transition recovers it. Limited to AirPlay so a real pause on the
|
|
7
|
+
/// local route is never nudged.
|
|
9
8
|
struct AirPlayStallJudgement {
|
|
10
9
|
let previous: PlayerTimeControlStatus?
|
|
11
10
|
let current: PlayerTimeControlStatus
|
|
12
|
-
///
|
|
13
|
-
/// `.noItemToPlay` (the AirPlay-stall signature, not a normal rebuffer).
|
|
11
|
+
/// The previous waiting reason was `.noItemToPlay`: the stall's signature, not a rebuffer.
|
|
14
12
|
let previousWaitingReasonWasNoItemToPlay: Bool
|
|
15
13
|
let isAirPlay: Bool
|
|
16
14
|
let playWhenReady: Bool
|
|
@@ -14,8 +14,8 @@ protocol AudioSessionPlayer: AnyObject {
|
|
|
14
14
|
|
|
15
15
|
extension Player: AudioSessionPlayer {}
|
|
16
16
|
|
|
17
|
-
/// Owns the app's `AVAudioSession`:
|
|
18
|
-
/// route-change, media-services-reset and volume observers
|
|
17
|
+
/// Owns the app's `AVAudioSession`: category, activation and release, and the interruption,
|
|
18
|
+
/// route-change, media-services-reset and volume observers.
|
|
19
19
|
///
|
|
20
20
|
/// The session is configured at setup but activated only when playback produces output:
|
|
21
21
|
/// activating a non-mixable session interrupts other apps' audio, which must not happen at
|
|
@@ -37,12 +37,11 @@ final class AudioSessionController {
|
|
|
37
37
|
|
|
38
38
|
private var releaseWork: DispatchWorkItem?
|
|
39
39
|
|
|
40
|
-
///
|
|
41
|
-
///
|
|
42
|
-
/// their order.
|
|
40
|
+
/// `setActive` blocks until the system has changed the session, long enough to stall the main
|
|
41
|
+
/// thread. Serial, so a release and a quick re-activation keep their order.
|
|
43
42
|
private let activationQueue = DispatchQueue(label: "com.audiobrowser.audio-session", qos: .userInitiated)
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
// Touched only by `init` and `deinit`.
|
|
46
45
|
private nonisolated(unsafe) var observers: [NSObjectProtocol] = []
|
|
47
46
|
private var volumeObservation: NSKeyValueObservation?
|
|
48
47
|
|
|
@@ -93,8 +92,8 @@ final class AudioSessionController {
|
|
|
93
92
|
applyCategory()
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
/// Activates the session
|
|
97
|
-
///
|
|
95
|
+
/// Activates the session and cancels a pending release. `then` runs on the main actor once the
|
|
96
|
+
/// activation has run, whether or not it succeeded.
|
|
98
97
|
func activate(then: (@MainActor @Sendable () -> Void)? = nil) {
|
|
99
98
|
cancelRelease()
|
|
100
99
|
activationQueue.async {
|
|
@@ -104,7 +103,7 @@ final class AudioSessionController {
|
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
/// Releases the session after 3 s unless playback resumes, so other apps' audio can come back.
|
|
107
|
-
/// Debounced: iOS dislikes deactivating while audio trails off, and a quick pause
|
|
106
|
+
/// Debounced: iOS dislikes deactivating while audio trails off, and a quick pause and resume
|
|
108
107
|
/// should not thrash it.
|
|
109
108
|
func scheduleRelease() {
|
|
110
109
|
releaseWork?.cancel()
|
|
@@ -157,8 +156,8 @@ final class AudioSessionController {
|
|
|
157
156
|
guard let type = type.flatMap(AVAudioSession.InterruptionType.init(rawValue:)) else { return }
|
|
158
157
|
switch type {
|
|
159
158
|
case .began:
|
|
160
|
-
// iOS 17+ also begins one, never ended, when an output route disappears; the route
|
|
161
|
-
//
|
|
159
|
+
// iOS 17+ also begins one, never ended, when an output route disappears; the route change
|
|
160
|
+
// handles that.
|
|
162
161
|
if #available(iOS 17.0, *),
|
|
163
162
|
let reason,
|
|
164
163
|
AVAudioSession.InterruptionReason(rawValue: reason) == .routeDisconnected
|
|
@@ -168,8 +167,8 @@ final class AudioSessionController {
|
|
|
168
167
|
player?.handleInterruptionBegan()
|
|
169
168
|
case .ended:
|
|
170
169
|
let shouldResume = options.map { AVAudioSession.InterruptionOptions(rawValue: $0).contains(.shouldResume) } ?? false
|
|
171
|
-
// Reactivate only when a resume follows, and resume once
|
|
172
|
-
//
|
|
170
|
+
// Reactivate only when a resume follows, and resume once active: activating while staying
|
|
171
|
+
// paused would hold a non-mixable session with nothing to release it.
|
|
173
172
|
if shouldResume, player?.willResumeAfterInterruption == true {
|
|
174
173
|
activate { [weak self] in self?.player?.handleInterruptionEnded(shouldResume: true) }
|
|
175
174
|
} else {
|
|
@@ -181,8 +180,8 @@ final class AudioSessionController {
|
|
|
181
180
|
}
|
|
182
181
|
|
|
183
182
|
private func handleRouteChange(reason: UInt?) {
|
|
184
|
-
// The output disappeared (headphones unplugged, a speaker off): pause
|
|
185
|
-
//
|
|
183
|
+
// The output disappeared (headphones unplugged, a speaker off): pause rather than carry on
|
|
184
|
+
// from the built-in speaker.
|
|
186
185
|
if let reason, AVAudioSession.RouteChangeReason(rawValue: reason) == .oldDeviceUnavailable {
|
|
187
186
|
player?.handleRouteDisconnected()
|
|
188
187
|
}
|
|
@@ -22,8 +22,8 @@ struct DeferredSeek {
|
|
|
22
22
|
|
|
23
23
|
private(set) var state: State = .idle
|
|
24
24
|
|
|
25
|
-
///
|
|
26
|
-
///
|
|
25
|
+
/// The item a seek was issued against. `reset()` bumps it, so the completion of a seek against
|
|
26
|
+
/// the previous item can tell it is stale.
|
|
27
27
|
private(set) var generation = 0
|
|
28
28
|
|
|
29
29
|
/// The target, pending or in flight; `seekBy` offsets from it.
|