@javascriptcommon/react-native-track-player 1.2.9 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -21
- package/README.md +8 -0
- package/android/build.gradle +92 -18
- package/android/proguard-rules.txt +0 -3
- package/android/src/main/AndroidManifest.xml +10 -13
- package/android/src/main/java/com/doublesymmetry/trackplayer/HeadlessJsMediaService.kt +199 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/TrackPlayer.kt +33 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/extensions/AudioPlayerStateExt.kt +19 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/extensions/EnumExtensions.kt +5 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/extensions/NumberExt.kt +13 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/model/MetadataAdapter.kt +227 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/model/NowPlayingMetadata.kt +16 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/model/PlaybackMetadata.kt +203 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/model/State.kt +13 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/model/Track.kt +67 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/model/TrackAudioItem.kt +18 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/model/TrackMetadata.kt +38 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicEvents.kt +67 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt +778 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt +1286 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/utils/AppForegroundTracker.kt +35 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/utils/BundleUtils.kt +147 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/utils/CoilBitmapLoader.kt +65 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/utils/MediaItemBuilder.kt +41 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/utils/RejectionException.kt +11 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/video/TrackPlayerVideoView.kt +42 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/video/TrackPlayerVideoViewManager.kt +18 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/event/EventHolder.kt +30 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/event/PlayerEventHolder.kt +124 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/AudioContentType.kt +10 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/AudioItem.kt +118 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/AudioItemTransitionReason.kt +33 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/AudioPlayerState.kt +30 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/BufferConfig.kt +8 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/CacheConfig.kt +17 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/Capability.kt +19 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/CustomButton.kt +19 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/FocusChangeData.kt +3 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/MediaSessionCallback.kt +17 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlayWhenReadyChangeData.kt +3 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlaybackEndedReason.kt +5 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlaybackError.kt +6 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlayerConfig.kt +36 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlayerOptions.kt +40 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PositionChangedReason.kt +39 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/RepeatMode.kt +16 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/WakeMode.kt +7 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/AudioPlayer.kt +756 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/ForwardingPlayer.java +1124 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/QueuedAudioPlayer.kt +279 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/components/APMRenderersFactory.kt +33 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/components/Buffer.kt +34 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/components/Cache.kt +27 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/components/FocusManager.kt +59 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/components/MediaFactory.kt +130 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/processors/TeeListener.kt +171 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/service/MusicService.kt +127 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/utils/FFT.java +99 -0
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/utils/Utils.kt +113 -0
- package/android/src/main/res/drawable/baseline_repeat_24.xml +5 -0
- package/android/src/main/res/drawable/baseline_repeat_one_24.xml +5 -0
- package/android/src/main/res/drawable/forward.xml +5 -0
- package/android/src/main/res/drawable/heart_24px.xml +5 -0
- package/android/src/main/res/drawable/hearte_24px.xml +5 -0
- package/android/src/main/res/drawable/ifl_24px.xml +5 -0
- package/android/src/main/res/drawable/rewind.xml +5 -0
- package/android/src/main/res/drawable/shuffle_24px.xml +5 -0
- package/android/src/main/res/values/strings.xml +5 -0
- package/android/src/main/res/xml/automotive_app_desc.xml +3 -0
- package/ios/Example/SwiftAudio/Assets.xcassets/22AMI.imageset/22AMillion.jpg +0 -0
- package/ios/Example/SwiftAudio/Assets.xcassets/22AMI.imageset/Contents.json +21 -0
- package/ios/Example/SwiftAudio/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/ios/Example/SwiftAudio/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
- package/ios/Example/SwiftAudio/Assets.xcassets/Contents.json +6 -0
- package/ios/Example/SwiftAudio/Assets.xcassets/cover.imageset/Contents.json +21 -0
- package/ios/Example/SwiftAudio/Assets.xcassets/cover.imageset/cover.jpg +0 -0
- package/ios/Example/SwiftAudio/AudioController.swift +46 -0
- package/ios/Example/SwiftAudio/Extensions.swift +22 -0
- package/ios/Example/SwiftAudio/PlayerView.swift +172 -0
- package/ios/Example/SwiftAudio/PlayerViewModel.swift +120 -0
- package/ios/Example/SwiftAudio/Preview Content/Preview Assets.xcassets/Contents.json +6 -0
- package/ios/Example/SwiftAudio/QueueView.swift +65 -0
- package/ios/{TrackPlayer.xcodeproj/xcuserdata/marco.xcuserdatad/xcschemes/xcschememanagement.plist → Example/SwiftAudio/SwiftAudio.entitlements} +6 -8
- package/ios/Example/SwiftAudio/SwiftAudioApp.swift +17 -0
- package/ios/Example/SwiftAudio.xcodeproj/project.pbxproj +412 -0
- package/ios/{TrackPlayer.xcodeproj → Example/SwiftAudio.xcodeproj}/project.xcworkspace/contents.xcworkspacedata +1 -1
- package/ios/RNTrackPlayer/Models/Capabilities.swift +39 -4
- package/ios/RNTrackPlayer/Models/MediaURL.swift +12 -6
- package/ios/RNTrackPlayer/Models/MetadataAdapter.swift +147 -0
- package/ios/RNTrackPlayer/Models/PitchAlgorithms.swift +13 -0
- package/ios/RNTrackPlayer/Models/SessionCategories.swift +106 -0
- package/ios/RNTrackPlayer/Models/State.swift +26 -0
- package/ios/RNTrackPlayer/Models/Track.swift +74 -54
- package/ios/RNTrackPlayer/RNTrackPlayer.swift +867 -406
- package/ios/RNTrackPlayer/Support/RNTrackPlayer-Bridging-Header.h +1 -0
- package/ios/RNTrackPlayer/TrackPlayer.h +14 -0
- package/ios/RNTrackPlayer/TrackPlayer.mm +249 -0
- package/ios/RNTrackPlayer/Utils/EventType.swift +45 -0
- package/ios/RNTrackPlayer/Utils/Metadata.swift +60 -0
- package/ios/RNTrackPlayer/Video/RNTrackPlayerVideoView.swift +83 -0
- package/ios/RNTrackPlayer/Video/RNTrackPlayerVideoViewManager.m +5 -0
- package/ios/RNTrackPlayer/Video/RNTrackPlayerVideoViewManager.swift +17 -0
- package/ios/SwiftAudioEx/Package.swift +20 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AVPlayerWrapper/AVPlayerWrapper.swift +531 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AVPlayerWrapper/AVPlayerWrapperDelegate.swift +27 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AVPlayerWrapper/AVPlayerWrapperProtocol.swift +69 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AVPlayerWrapper/AVPlayerWrapperState.swift +43 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioItem.swift +158 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioPlayer.swift +459 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioPlayerError.swift +26 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioSessionController/AudioSession.swift +33 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioSessionController/AudioSessionController.swift +135 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioTap.swift +96 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Event.swift +155 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/MediaItemProperty.swift +95 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoCenter.swift +17 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoController.swift +73 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoControllerProtocol.swift +26 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoKeyValue.swift +14 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoProperty.swift +234 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Observer/AVPlayerItemNotificationObserver.swift +102 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Observer/AVPlayerItemObserver.swift +136 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Observer/AVPlayerObserver.swift +120 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Observer/AVPlayerTimeObserver.swift +112 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/QueueManager.swift +356 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/QueuedAudioPlayer.swift +236 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/RemoteCommandController/RemoteCommand.swift +170 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/RemoteCommandController/RemoteCommandController.swift +206 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/RepeatMode.swift +15 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/TimeEventFrequency.swift +26 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Utils/DispatchQueueType.swift +18 -0
- package/ios/SwiftAudioEx/Sources/SwiftAudioEx/WaveformAudioTap.swift +159 -0
- package/lib/specs/NativeTrackPlayer.d.ts +134 -0
- package/lib/specs/NativeTrackPlayer.js +4 -0
- package/lib/src/TrackPlayerModule.web.d.ts +2 -0
- package/lib/src/TrackPlayerModule.web.js +2 -0
- package/lib/src/VideoView.d.ts +16 -0
- package/lib/src/VideoView.js +25 -0
- package/lib/src/constants/AndroidAudioContentType.d.ts +35 -0
- package/lib/src/constants/AndroidAudioContentType.js +36 -0
- package/lib/src/constants/AndroidAutoContentStyle.d.ts +10 -0
- package/lib/src/constants/AndroidAutoContentStyle.js +11 -0
- package/lib/src/constants/AppKilledPlaybackBehavior.d.ts +17 -0
- package/lib/src/constants/AppKilledPlaybackBehavior.js +18 -0
- package/lib/src/constants/Capability.d.ts +17 -0
- package/lib/src/constants/Capability.js +19 -0
- package/lib/src/constants/Event.d.ts +172 -0
- package/lib/src/constants/Event.js +173 -0
- package/lib/src/constants/IOSCategory.d.ts +36 -0
- package/lib/src/constants/IOSCategory.js +37 -0
- package/lib/src/constants/IOSCategoryMode.d.ts +47 -0
- package/lib/src/constants/IOSCategoryMode.js +48 -0
- package/lib/src/constants/IOSCategoryOptions.d.ts +44 -0
- package/lib/src/constants/IOSCategoryOptions.js +45 -0
- package/lib/src/constants/MediaItemPlayable.d.ts +4 -0
- package/lib/src/constants/MediaItemPlayable.js +5 -0
- package/lib/src/constants/PitchAlgorithm.d.ts +14 -0
- package/lib/src/constants/PitchAlgorithm.js +16 -0
- package/lib/src/constants/RatingType.d.ts +8 -0
- package/lib/src/constants/RatingType.js +10 -0
- package/lib/src/constants/RepeatMode.d.ts +8 -0
- package/lib/src/constants/RepeatMode.js +10 -0
- package/lib/src/constants/State.d.ts +34 -0
- package/lib/src/constants/State.js +35 -0
- package/lib/src/constants/TrackType.d.ts +6 -0
- package/lib/src/constants/TrackType.js +7 -0
- package/lib/src/constants/index.d.ts +14 -0
- package/lib/src/constants/index.js +14 -0
- package/lib/src/hooks/index.d.ts +6 -0
- package/lib/src/hooks/index.js +6 -0
- package/lib/src/hooks/useActiveTrack.d.ts +2 -0
- package/lib/src/hooks/useActiveTrack.js +28 -0
- package/lib/src/hooks/useAppIsInBackground.d.ts +1 -0
- package/lib/src/hooks/useAppIsInBackground.js +16 -0
- package/lib/src/hooks/useIsPlaying.d.ts +35 -0
- package/lib/src/hooks/useIsPlaying.js +50 -0
- package/lib/src/hooks/usePlayWhenReady.d.ts +1 -0
- package/lib/src/hooks/usePlayWhenReady.js +27 -0
- package/lib/src/hooks/usePlaybackState.d.ts +10 -0
- package/lib/src/hooks/usePlaybackState.js +35 -0
- package/lib/src/hooks/useProgress.d.ts +7 -0
- package/lib/src/hooks/useProgress.js +55 -0
- package/lib/src/hooks/useTrackPlayerEvents.d.ts +8 -0
- package/lib/src/hooks/useTrackPlayerEvents.js +30 -0
- package/lib/src/index.d.ts +6 -0
- package/lib/src/index.js +6 -0
- package/lib/src/interfaces/AndroidAutoBrowseTree.d.ts +5 -0
- package/lib/src/interfaces/AndroidAutoBrowseTree.js +1 -0
- package/lib/src/interfaces/AndroidOptions.d.ts +41 -0
- package/lib/src/interfaces/AndroidOptions.js +1 -0
- package/lib/src/interfaces/CustomButtons.d.ts +5 -0
- package/lib/src/interfaces/CustomButtons.js +1 -0
- package/lib/src/interfaces/FeedbackOptions.d.ts +6 -0
- package/lib/src/interfaces/FeedbackOptions.js +1 -0
- package/lib/src/interfaces/MediaItem.d.ts +18 -0
- package/lib/src/interfaces/MediaItem.js +1 -0
- package/lib/src/interfaces/MetadataOptions.d.ts +3 -0
- package/lib/src/interfaces/MetadataOptions.js +1 -0
- package/lib/src/interfaces/NowPlayingMetadata.d.ts +4 -0
- package/lib/src/interfaces/NowPlayingMetadata.js +1 -0
- package/lib/src/interfaces/PlaybackState.d.ts +8 -0
- package/lib/src/interfaces/PlaybackState.js +1 -0
- package/lib/src/interfaces/PlayerOptions.d.ts +132 -0
- package/lib/src/interfaces/PlayerOptions.js +1 -0
- package/lib/src/interfaces/Progress.d.ts +15 -0
- package/lib/src/interfaces/Progress.js +1 -0
- package/lib/src/interfaces/ResourceObject.d.ts +1 -0
- package/lib/src/interfaces/ResourceObject.js +1 -0
- package/lib/src/interfaces/ServiceHandler.d.ts +1 -0
- package/lib/src/interfaces/ServiceHandler.js +1 -0
- package/lib/src/interfaces/Track.d.ts +21 -0
- package/lib/src/interfaces/Track.js +1 -0
- package/lib/src/interfaces/TrackMetadataBase.d.ts +28 -0
- package/lib/src/interfaces/TrackMetadataBase.js +1 -0
- package/lib/src/interfaces/UpdateOptions.d.ts +52 -0
- package/lib/src/interfaces/UpdateOptions.js +1 -0
- package/lib/src/interfaces/events/AudioMetadataReceivedEvent.d.ts +33 -0
- package/lib/src/interfaces/events/AudioMetadataReceivedEvent.js +1 -0
- package/lib/src/interfaces/events/ControllerConnectedEvent.d.ts +8 -0
- package/lib/src/interfaces/events/ControllerConnectedEvent.js +1 -0
- package/lib/src/interfaces/events/EventPayloadByEvent.d.ts +77 -0
- package/lib/src/interfaces/events/EventPayloadByEvent.js +1 -0
- package/lib/src/interfaces/events/FFTUpdateEvent.d.ts +7 -0
- package/lib/src/interfaces/events/FFTUpdateEvent.js +1 -0
- package/lib/src/interfaces/events/PlaybackActiveTrackChangedEvent.d.ts +24 -0
- package/lib/src/interfaces/events/PlaybackActiveTrackChangedEvent.js +1 -0
- package/lib/src/interfaces/events/PlaybackAnimatedVolumeChangedEvent.d.ts +4 -0
- package/lib/src/interfaces/events/PlaybackAnimatedVolumeChangedEvent.js +1 -0
- package/lib/src/interfaces/events/PlaybackErrorEvent.d.ts +6 -0
- package/lib/src/interfaces/events/PlaybackErrorEvent.js +1 -0
- package/lib/src/interfaces/events/PlaybackMetadataReceivedEvent.d.ts +16 -0
- package/lib/src/interfaces/events/PlaybackMetadataReceivedEvent.js +1 -0
- package/lib/src/interfaces/events/PlaybackPlayWhenReadyChangedEvent.d.ts +4 -0
- package/lib/src/interfaces/events/PlaybackPlayWhenReadyChangedEvent.js +1 -0
- package/lib/src/interfaces/events/PlaybackProgressUpdatedEvent.d.ts +4 -0
- package/lib/src/interfaces/events/PlaybackProgressUpdatedEvent.js +1 -0
- package/lib/src/interfaces/events/PlaybackQueueEndedEvent.d.ts +9 -0
- package/lib/src/interfaces/events/PlaybackQueueEndedEvent.js +1 -0
- package/lib/src/interfaces/events/PlaybackResumeEvent.d.ts +3 -0
- package/lib/src/interfaces/events/PlaybackResumeEvent.js +1 -0
- package/lib/src/interfaces/events/PlaybackTrackChangedEvent.d.ts +11 -0
- package/lib/src/interfaces/events/PlaybackTrackChangedEvent.js +1 -0
- package/lib/src/interfaces/events/PlayerErrorEvent.d.ts +6 -0
- package/lib/src/interfaces/events/PlayerErrorEvent.js +1 -0
- package/lib/src/interfaces/events/RemoteBrowseEvent.d.ts +4 -0
- package/lib/src/interfaces/events/RemoteBrowseEvent.js +1 -0
- package/lib/src/interfaces/events/RemoteCustomActionEvent.d.ts +7 -0
- package/lib/src/interfaces/events/RemoteCustomActionEvent.js +1 -0
- package/lib/src/interfaces/events/RemoteDuckEvent.d.ts +13 -0
- package/lib/src/interfaces/events/RemoteDuckEvent.js +1 -0
- package/lib/src/interfaces/events/RemoteJumpBackwardEvent.d.ts +7 -0
- package/lib/src/interfaces/events/RemoteJumpBackwardEvent.js +1 -0
- package/lib/src/interfaces/events/RemoteJumpForwardEvent.d.ts +7 -0
- package/lib/src/interfaces/events/RemoteJumpForwardEvent.js +1 -0
- package/lib/src/interfaces/events/RemotePlayIdEvent.d.ts +4 -0
- package/lib/src/interfaces/events/RemotePlayIdEvent.js +1 -0
- package/lib/src/interfaces/events/RemotePlaySearchEvent.d.ts +9 -0
- package/lib/src/interfaces/events/RemotePlaySearchEvent.js +1 -0
- package/lib/src/interfaces/events/RemoteSearchEvent.d.ts +3 -0
- package/lib/src/interfaces/events/RemoteSearchEvent.js +1 -0
- package/lib/src/interfaces/events/RemoteSeekEvent.d.ts +4 -0
- package/lib/src/interfaces/events/RemoteSeekEvent.js +1 -0
- package/lib/src/interfaces/events/RemoteSetRatingEvent.d.ts +4 -0
- package/lib/src/interfaces/events/RemoteSetRatingEvent.js +1 -0
- package/lib/src/interfaces/events/RemoteSkipEvent.d.ts +3 -0
- package/lib/src/interfaces/events/RemoteSkipEvent.js +1 -0
- package/lib/src/interfaces/events/index.d.ts +20 -0
- package/lib/src/interfaces/events/index.js +20 -0
- package/lib/src/interfaces/index.d.ts +15 -0
- package/lib/src/interfaces/index.js +15 -0
- package/lib/src/resolveAssetSource.d.ts +2 -0
- package/lib/src/resolveAssetSource.js +3 -0
- package/lib/src/resolveAssetSource.web.d.ts +2 -0
- package/lib/src/resolveAssetSource.web.js +8 -0
- package/lib/src/trackPlayer.d.ts +371 -0
- package/lib/src/trackPlayer.js +627 -0
- package/lib/web/TrackPlayer/Player.d.ts +40 -0
- package/lib/web/TrackPlayer/Player.js +188 -0
- package/lib/web/TrackPlayer/PlaylistPlayer.d.ts +31 -0
- package/lib/web/TrackPlayer/PlaylistPlayer.js +181 -0
- package/lib/web/TrackPlayer/RepeatMode.d.ts +5 -0
- package/lib/web/TrackPlayer/RepeatMode.js +6 -0
- package/lib/web/TrackPlayer/SetupNotCalledError.d.ts +3 -0
- package/lib/web/TrackPlayer/SetupNotCalledError.js +5 -0
- package/lib/web/TrackPlayer/index.d.ts +3 -0
- package/lib/web/TrackPlayer/index.js +3 -0
- package/lib/web/TrackPlayerModule.d.ts +63 -0
- package/lib/web/TrackPlayerModule.js +153 -0
- package/lib/web/index.d.ts +3 -0
- package/lib/web/index.js +3 -0
- package/package.json +85 -6
- package/react-native-track-player.podspec +13 -13
- package/specs/NativeTrackPlayer.ts +153 -0
- package/src/TrackPlayerModule.web.ts +2 -0
- package/src/VideoView.tsx +51 -0
- package/src/constants/AndroidAudioContentType.ts +35 -0
- package/src/constants/AndroidAutoContentStyle.ts +10 -0
- package/src/constants/AppKilledPlaybackBehavior.ts +19 -0
- package/src/constants/Capability.ts +19 -0
- package/src/constants/Event.ts +173 -0
- package/src/constants/IOSCategory.ts +36 -0
- package/src/constants/IOSCategoryMode.ts +47 -0
- package/src/constants/IOSCategoryOptions.ts +44 -0
- package/src/constants/MediaItemPlayable.ts +4 -0
- package/src/constants/PitchAlgorithm.ts +16 -0
- package/src/constants/RatingType.ts +10 -0
- package/src/constants/RepeatMode.ts +10 -0
- package/src/constants/State.ts +34 -0
- package/src/constants/TrackType.ts +6 -0
- package/src/constants/index.ts +14 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useActiveTrack.ts +36 -0
- package/src/hooks/useAppIsInBackground.ts +20 -0
- package/src/hooks/useIsPlaying.ts +56 -0
- package/src/hooks/usePlayWhenReady.ts +37 -0
- package/src/hooks/usePlaybackState.ts +45 -0
- package/src/hooks/useProgress.ts +64 -0
- package/src/hooks/useTrackPlayerEvents.ts +48 -0
- package/src/index.ts +8 -0
- package/src/interfaces/AndroidAutoBrowseTree.ts +6 -0
- package/src/interfaces/AndroidOptions.ts +48 -0
- package/src/interfaces/CustomButtons.ts +6 -0
- package/src/interfaces/FeedbackOptions.ts +7 -0
- package/src/interfaces/MediaItem.ts +19 -0
- package/src/interfaces/MetadataOptions.ts +4 -0
- package/src/interfaces/NowPlayingMetadata.ts +5 -0
- package/src/interfaces/PlaybackState.ts +11 -0
- package/src/interfaces/PlayerOptions.ts +138 -0
- package/src/interfaces/Progress.ts +15 -0
- package/src/interfaces/ResourceObject.ts +1 -0
- package/src/interfaces/ServiceHandler.ts +1 -0
- package/src/interfaces/Track.ts +23 -0
- package/src/interfaces/TrackMetadataBase.ts +29 -0
- package/src/interfaces/UpdateOptions.ts +59 -0
- package/src/interfaces/events/AudioMetadataReceivedEvent.ts +37 -0
- package/src/interfaces/events/ControllerConnectedEvent.ts +9 -0
- package/src/interfaces/events/EventPayloadByEvent.ts +80 -0
- package/src/interfaces/events/FFTUpdateEvent.ts +9 -0
- package/src/interfaces/events/PlaybackActiveTrackChangedEvent.ts +29 -0
- package/src/interfaces/events/PlaybackAnimatedVolumeChangedEvent.ts +4 -0
- package/src/interfaces/events/PlaybackErrorEvent.ts +6 -0
- package/src/interfaces/events/PlaybackMetadataReceivedEvent.ts +16 -0
- package/src/interfaces/events/PlaybackPlayWhenReadyChangedEvent.ts +4 -0
- package/src/interfaces/events/PlaybackProgressUpdatedEvent.ts +5 -0
- package/src/interfaces/events/PlaybackQueueEndedEvent.ts +9 -0
- package/src/interfaces/events/PlaybackResumeEvent.ts +5 -0
- package/src/interfaces/events/PlaybackTrackChangedEvent.ts +11 -0
- package/src/interfaces/events/PlayerErrorEvent.ts +6 -0
- package/src/interfaces/events/RemoteBrowseEvent.ts +4 -0
- package/src/interfaces/events/RemoteCustomActionEvent.ts +7 -0
- package/src/interfaces/events/RemoteDuckEvent.ts +13 -0
- package/src/interfaces/events/RemoteJumpBackwardEvent.ts +7 -0
- package/src/interfaces/events/RemoteJumpForwardEvent.ts +7 -0
- package/src/interfaces/events/RemotePlayIdEvent.ts +4 -0
- package/src/interfaces/events/RemotePlaySearchEvent.ts +21 -0
- package/src/interfaces/events/RemoteSearchEvent.ts +3 -0
- package/src/interfaces/events/RemoteSeekEvent.ts +4 -0
- package/src/interfaces/events/RemoteSetRatingEvent.ts +5 -0
- package/src/interfaces/events/RemoteSkipEvent.ts +3 -0
- package/src/interfaces/events/index.ts +20 -0
- package/src/interfaces/index.ts +15 -0
- package/src/resolveAssetSource.ts +3 -0
- package/src/resolveAssetSource.web.ts +10 -0
- package/src/trackPlayer.ts +806 -0
- package/web/TrackPlayer/Player.ts +201 -0
- package/web/TrackPlayer/PlaylistPlayer.ts +215 -0
- package/web/TrackPlayer/RepeatMode.ts +6 -0
- package/web/TrackPlayer/SetupNotCalledError.ts +5 -0
- package/web/TrackPlayer/index.ts +3 -0
- package/web/TrackPlayerModule.ts +181 -0
- package/web/index.ts +4 -0
- package/CHANGELOG.md +0 -75
- package/android/react-native-music-control.iml +0 -139
- package/android/react-native-track-player.iml +0 -151
- package/android/src/main/java/com/guichaguri/trackplayer/TrackPlayer.java +0 -28
- package/android/src/main/java/com/guichaguri/trackplayer/module/MusicEvents.java +0 -55
- package/android/src/main/java/com/guichaguri/trackplayer/module/MusicModule.java +0 -298
- package/android/src/main/java/com/guichaguri/trackplayer/service/HeadlessJsMediaService.java +0 -174
- package/android/src/main/java/com/guichaguri/trackplayer/service/MusicBinder.java +0 -47
- package/android/src/main/java/com/guichaguri/trackplayer/service/MusicManager.java +0 -383
- package/android/src/main/java/com/guichaguri/trackplayer/service/MusicService.java +0 -271
- package/android/src/main/java/com/guichaguri/trackplayer/service/Utils.java +0 -243
- package/android/src/main/java/com/guichaguri/trackplayer/service/metadata/ButtonEvents.java +0 -148
- package/android/src/main/java/com/guichaguri/trackplayer/service/metadata/MetadataManager.java +0 -379
- package/android/src/main/java/com/guichaguri/trackplayer/service/models/Track.java +0 -141
- package/android/src/main/java/com/guichaguri/trackplayer/service/models/TrackType.java +0 -35
- package/android/src/main/res/drawable-hdpi/ic_forward.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_logo.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_next.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_previous.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_rewind.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_stop.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_forward.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_logo.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_next.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_previous.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_rewind.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_stop.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_forward.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_logo.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_next.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_previous.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_rewind.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_stop.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_forward.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_logo.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_next.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_previous.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_rewind.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_stop.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_forward.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_logo.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_next.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_previous.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_rewind.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_stop.png +0 -0
- package/index.d.ts +0 -174
- package/index.js +0 -4
- package/ios/RNTrackPlayer/RNTrackPlayerBridge.h +0 -12
- package/ios/RNTrackPlayer/RNTrackPlayerBridge.m +0 -29
- package/ios/TrackPlayer.xcodeproj/project.pbxproj +0 -495
- package/ios/TrackPlayer.xcodeproj/project.xcworkspace/xcuserdata/marco.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/lib/ProgressComponent.js +0 -70
- package/lib/eventTypes.js +0 -28
- package/lib/hooks.js +0 -160
- package/lib/index.js +0 -177
- /package/ios/{TrackPlayer.xcodeproj → Example/SwiftAudio.xcodeproj}/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioSessionController/AudioSessionController.swift
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AudioSessionController.swift
|
|
3
|
+
// SwiftAudio
|
|
4
|
+
//
|
|
5
|
+
// Created by Jørgen Henrichsen on 19/03/2018.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import AVFoundation
|
|
10
|
+
|
|
11
|
+
public enum InterruptionType: Equatable {
|
|
12
|
+
case began
|
|
13
|
+
case ended(shouldResume: Bool)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#if os(iOS)
|
|
17
|
+
|
|
18
|
+
public protocol AudioSessionControllerDelegate: AnyObject {
|
|
19
|
+
func handleInterruption(type: InterruptionType)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
Simple controller for the `AVAudioSession`. If you need more advanced options, just use the `AVAudioSession` directly.
|
|
24
|
+
- warning: Do not combine usage of this and `AVAudioSession` directly, chose one.
|
|
25
|
+
*/
|
|
26
|
+
public class AudioSessionController {
|
|
27
|
+
|
|
28
|
+
public static let shared = AudioSessionController()
|
|
29
|
+
|
|
30
|
+
private let audioSession: AudioSession
|
|
31
|
+
private let notificationCenter: NotificationCenter = NotificationCenter.default
|
|
32
|
+
private var _isObservingForInterruptions: Bool = false
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
True if another app is currently playing audio.
|
|
36
|
+
*/
|
|
37
|
+
public var isOtherAudioPlaying: Bool {
|
|
38
|
+
audioSession.isOtherAudioPlaying
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
True if the audiosession is active.
|
|
43
|
+
|
|
44
|
+
- warning: This will only be correct if the audiosession is activated through this class!
|
|
45
|
+
*/
|
|
46
|
+
public var audioSessionIsActive: Bool = false
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
Wheter notifications for interruptions are being observed or not.
|
|
50
|
+
This is enabled by default.
|
|
51
|
+
Set this to false to disable the behaviour.
|
|
52
|
+
*/
|
|
53
|
+
public var isObservingForInterruptions: Bool {
|
|
54
|
+
get { _isObservingForInterruptions }
|
|
55
|
+
set {
|
|
56
|
+
if newValue == _isObservingForInterruptions {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if newValue {
|
|
61
|
+
registerForInterruptionNotification()
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
unregisterForInterruptionNotification()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public weak var delegate: AudioSessionControllerDelegate?
|
|
70
|
+
|
|
71
|
+
init(audioSession: AudioSession = AVAudioSession.sharedInstance()) {
|
|
72
|
+
self.audioSession = audioSession
|
|
73
|
+
registerForInterruptionNotification()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public func activateSession() throws {
|
|
77
|
+
do {
|
|
78
|
+
try audioSession.setActive(true, options: [])
|
|
79
|
+
audioSessionIsActive = true
|
|
80
|
+
}
|
|
81
|
+
catch let error { throw error }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public func deactivateSession() throws {
|
|
85
|
+
do {
|
|
86
|
+
try audioSession.setActive(false, options: [])
|
|
87
|
+
audioSessionIsActive = false
|
|
88
|
+
}
|
|
89
|
+
catch let error { throw error }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public func set(category: AVAudioSession.Category) throws {
|
|
93
|
+
try audioSession.setCategory(category, mode: audioSession.mode, options: audioSession.categoryOptions)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// MARK: - Interruptions
|
|
97
|
+
|
|
98
|
+
private func registerForInterruptionNotification() {
|
|
99
|
+
notificationCenter.addObserver(self,
|
|
100
|
+
selector: #selector(handleInterruption),
|
|
101
|
+
name: AVAudioSession.interruptionNotification,
|
|
102
|
+
object: nil)
|
|
103
|
+
_isObservingForInterruptions = true
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private func unregisterForInterruptionNotification() {
|
|
107
|
+
notificationCenter.removeObserver(self, name: AVAudioSession.interruptionNotification, object: nil)
|
|
108
|
+
_isObservingForInterruptions = false
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@objc func handleInterruption(notification: Notification) {
|
|
112
|
+
guard let userInfo = notification.userInfo,
|
|
113
|
+
let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt,
|
|
114
|
+
let type = AVAudioSession.InterruptionType(rawValue: typeValue) else {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
switch type {
|
|
119
|
+
case .began:
|
|
120
|
+
delegate?.handleInterruption(type: .began)
|
|
121
|
+
case .ended:
|
|
122
|
+
guard let typeValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt else {
|
|
123
|
+
delegate?.handleInterruption(type: .ended(shouldResume: false))
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let options = AVAudioSession.InterruptionOptions(rawValue: typeValue)
|
|
128
|
+
delegate?.handleInterruption(type: .ended(shouldResume: options.contains(.shouldResume)))
|
|
129
|
+
@unknown default: return
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#endif
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AudioTap.swift
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Sneed on 3/31/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import AVFoundation
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
Subclass this and set the AudioPlayer's `audioTap` property to start receiving the
|
|
13
|
+
audio stream.
|
|
14
|
+
*/
|
|
15
|
+
open class AudioTap {
|
|
16
|
+
// Called at tap initialization for a given player item. Use this to setup anything you might need.
|
|
17
|
+
open func initialize() { print("audioTap: initialize") }
|
|
18
|
+
// Called at teardown of the internal tap. Use this to reset any memory buffers you have created, etc.
|
|
19
|
+
open func finalize() { print("audioTap: finalize") }
|
|
20
|
+
// Called just before playback so you can perform setup based on the stream description.
|
|
21
|
+
open func prepare(description: AudioStreamBasicDescription) { print("audioTap: prepare") }
|
|
22
|
+
// Called just before finalize.
|
|
23
|
+
open func unprepare() { print("audioTap: unprepare") }
|
|
24
|
+
/**
|
|
25
|
+
Called periodically during audio stream – playback.
|
|
26
|
+
|
|
27
|
+
Example:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
func process(numberOfFrames: Int, buffer: UnsafeMutableAudioBufferListPointer) {
|
|
31
|
+
for channel in buffer {
|
|
32
|
+
// process audio samples here
|
|
33
|
+
//memset(channel.mData, 0, Int(channel.mDataByteSize))
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
*/
|
|
38
|
+
open func process(numberOfFrames: Int, buffer: UnsafeMutableAudioBufferListPointer) { print("audioTap: process") }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
extension AVPlayerWrapper {
|
|
42
|
+
internal func attachTap(_ tap: AudioTap?, to item: AVPlayerItem) {
|
|
43
|
+
guard let tap else { return }
|
|
44
|
+
guard let track = item.asset.tracks(withMediaType: .audio).first else {
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let audioMix = AVMutableAudioMix()
|
|
49
|
+
let params = AVMutableAudioMixInputParameters(track: track)
|
|
50
|
+
|
|
51
|
+
// we need to retain this pointer so it doesn't disappear out from under us.
|
|
52
|
+
// we'll then let it go after we finalize. If the tap changed upstream, we
|
|
53
|
+
// aren't going to pick up the new one until after this player item goes away.
|
|
54
|
+
let client = UnsafeMutableRawPointer(Unmanaged.passRetained(tap).toOpaque())
|
|
55
|
+
|
|
56
|
+
var callbacks = MTAudioProcessingTapCallbacks(version: kMTAudioProcessingTapCallbacksVersion_0, clientInfo: client)
|
|
57
|
+
{ tapRef, clientInfo, tapStorageOut in
|
|
58
|
+
// initial tap setup
|
|
59
|
+
guard let clientInfo else { return }
|
|
60
|
+
tapStorageOut.pointee = clientInfo
|
|
61
|
+
let audioTap = Unmanaged<AudioTap>.fromOpaque(clientInfo).takeUnretainedValue()
|
|
62
|
+
audioTap.initialize()
|
|
63
|
+
} finalize: { tapRef in
|
|
64
|
+
// clean up
|
|
65
|
+
let audioTap = Unmanaged<AudioTap>.fromOpaque(MTAudioProcessingTapGetStorage(tapRef)).takeUnretainedValue()
|
|
66
|
+
audioTap.finalize()
|
|
67
|
+
// we're done, we can let go of the pointer we retained.
|
|
68
|
+
Unmanaged.passUnretained(audioTap).release()
|
|
69
|
+
} prepare: { tapRef, maxFrames, processingFormat in
|
|
70
|
+
// allocate memory for sound processing
|
|
71
|
+
let audioTap = Unmanaged<AudioTap>.fromOpaque(MTAudioProcessingTapGetStorage(tapRef)).takeUnretainedValue()
|
|
72
|
+
audioTap.prepare(description: processingFormat.pointee)
|
|
73
|
+
} unprepare: { tapRef in
|
|
74
|
+
// deallocate memory for sound processing
|
|
75
|
+
let audioTap = Unmanaged<AudioTap>.fromOpaque(MTAudioProcessingTapGetStorage(tapRef)).takeUnretainedValue()
|
|
76
|
+
audioTap.unprepare()
|
|
77
|
+
} process: { tapRef, numberFrames, flags, bufferListInOut, numberFramesOut, flagsOut in
|
|
78
|
+
guard noErr == MTAudioProcessingTapGetSourceAudio(tapRef, numberFrames, bufferListInOut, flagsOut, nil, numberFramesOut) else {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// process sound data
|
|
83
|
+
let audioTap = Unmanaged<AudioTap>.fromOpaque(MTAudioProcessingTapGetStorage(tapRef)).takeUnretainedValue()
|
|
84
|
+
audioTap.process(numberOfFrames: numberFrames, buffer: UnsafeMutableAudioBufferListPointer(bufferListInOut))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var tapRef: MTAudioProcessingTap?
|
|
88
|
+
let error = MTAudioProcessingTapCreate(kCFAllocatorDefault, &callbacks, kMTAudioProcessingTapCreationFlag_PreEffects, &tapRef)
|
|
89
|
+
assert(error == noErr)
|
|
90
|
+
|
|
91
|
+
params.audioTapProcessor = tapRef
|
|
92
|
+
|
|
93
|
+
audioMix.inputParameters = [params]
|
|
94
|
+
item.audioMix = audioMix
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Event.swift
|
|
3
|
+
// SwiftAudio
|
|
4
|
+
//
|
|
5
|
+
// Created by Jørgen Henrichsen on 09/03/2019.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import MediaPlayer
|
|
10
|
+
|
|
11
|
+
extension AudioPlayer {
|
|
12
|
+
|
|
13
|
+
public typealias PlayWhenReadyChangeData = Bool
|
|
14
|
+
public typealias StateChangeEventData = AudioPlayerState
|
|
15
|
+
public typealias PlaybackEndEventData = PlaybackEndedReason
|
|
16
|
+
public typealias SecondElapseEventData = TimeInterval
|
|
17
|
+
public typealias FailEventData = Error?
|
|
18
|
+
public typealias SeekEventData = (seconds: Double, didFinish: Bool)
|
|
19
|
+
public typealias UpdateDurationEventData = Double
|
|
20
|
+
public typealias MetadataCommonEventData = [AVMetadataItem]
|
|
21
|
+
public typealias MetadataTimedEventData = [AVTimedMetadataGroup]
|
|
22
|
+
public typealias DidRecreateAVPlayerEventData = ()
|
|
23
|
+
public typealias CurrentItemEventData = (
|
|
24
|
+
item: AudioItem?,
|
|
25
|
+
index: Int?,
|
|
26
|
+
lastItem: AudioItem?,
|
|
27
|
+
lastIndex: Int?,
|
|
28
|
+
lastPosition: Double?
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
public struct EventHolder {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
Emitted when the `AudioPlayer`s state is changed
|
|
35
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
36
|
+
*/
|
|
37
|
+
public let stateChange: AudioPlayer.Event<StateChangeEventData> = AudioPlayer.Event()
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
Emitted when the `AudioPlayer#playWhenReady` has changed
|
|
41
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
42
|
+
*/
|
|
43
|
+
public let playWhenReadyChange: AudioPlayer.Event<PlayWhenReadyChangeData> = AudioPlayer.Event()
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
Emitted when the playback of the player, for some reason, has stopped.
|
|
47
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
48
|
+
*/
|
|
49
|
+
public let playbackEnd: AudioPlayer.Event<PlaybackEndEventData> = AudioPlayer.Event()
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
Emitted when a second is elapsed in the `AudioPlayer`.
|
|
53
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
54
|
+
*/
|
|
55
|
+
public let secondElapse: AudioPlayer.Event<SecondElapseEventData> = AudioPlayer.Event()
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
Emitted when the player encounters an error. This will ultimately result in the AVPlayer instance to be recreated.
|
|
59
|
+
If this event is emitted, it means you will need to load a new item in some way. Calling play() will not resume playback.
|
|
60
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
61
|
+
*/
|
|
62
|
+
public let fail: AudioPlayer.Event<FailEventData> = AudioPlayer.Event()
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
Emitted when the player is done attempting to seek.
|
|
66
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
67
|
+
*/
|
|
68
|
+
public let seek: AudioPlayer.Event<SeekEventData> = AudioPlayer.Event()
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
Emitted when the player updates its duration.
|
|
72
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
73
|
+
*/
|
|
74
|
+
public let updateDuration: AudioPlayer.Event<UpdateDurationEventData> = AudioPlayer.Event()
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
Emitted when the player receives common metadata.
|
|
78
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
79
|
+
*/
|
|
80
|
+
public let receiveCommonMetadata: AudioPlayer.Event<MetadataCommonEventData> = AudioPlayer.Event()
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
Emitted when the player receives timed metadata.
|
|
84
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
85
|
+
*/
|
|
86
|
+
public let receiveTimedMetadata: AudioPlayer.Event<MetadataTimedEventData> = AudioPlayer.Event()
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
Emitted when the player receives chapter metadata.
|
|
90
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
91
|
+
*/
|
|
92
|
+
public let receiveChapterMetadata: AudioPlayer.Event<MetadataTimedEventData> = AudioPlayer.Event()
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
Emitted when the underlying AVPlayer instance is recreated. Recreation happens if the current player fails.
|
|
96
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
97
|
+
- Note: It can be necessary to set the AVAudioSession's category again when this event is emitted.
|
|
98
|
+
*/
|
|
99
|
+
public let didRecreateAVPlayer: AudioPlayer.Event<()> = AudioPlayer.Event()
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
Emitted when the current track has changed.
|
|
103
|
+
- Important: Remember to dispatch to the main queue if any UI is updated in the event handler.
|
|
104
|
+
- Note: It is only fired for instances of a QueuedAudioPlayer.
|
|
105
|
+
*/
|
|
106
|
+
public let currentItem: AudioPlayer.Event<CurrentItemEventData> = AudioPlayer.Event()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public typealias EventClosure<EventData> = (EventData) -> Void
|
|
110
|
+
|
|
111
|
+
class Invoker<EventData> {
|
|
112
|
+
|
|
113
|
+
// Signals false if the listener object is nil
|
|
114
|
+
let invoke: (EventData) -> Bool
|
|
115
|
+
weak var listener: AnyObject?
|
|
116
|
+
|
|
117
|
+
init<Listener: AnyObject>(listener: Listener, closure: @escaping EventClosure<EventData>) {
|
|
118
|
+
self.listener = listener
|
|
119
|
+
invoke = { [weak listener] (data: EventData) in
|
|
120
|
+
guard let _ = listener else {
|
|
121
|
+
return false
|
|
122
|
+
}
|
|
123
|
+
closure(data)
|
|
124
|
+
return true
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public class Event<EventData> {
|
|
131
|
+
private let queue: DispatchQueue = DispatchQueue(label: "com.swiftAudioEx.eventQueue")
|
|
132
|
+
var invokers: [Invoker<EventData>] = []
|
|
133
|
+
|
|
134
|
+
public func addListener<Listener: AnyObject>(_ listener: Listener, _ closure: @escaping EventClosure<EventData>) {
|
|
135
|
+
queue.async {
|
|
136
|
+
self.invokers.append(Invoker(listener: listener, closure: closure))
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public func removeListener(_ listener: AnyObject) {
|
|
141
|
+
queue.async {
|
|
142
|
+
self.invokers = self.invokers.filter({ (invoker) -> Bool in
|
|
143
|
+
return invoker.listener !== listener
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
func emit(data: EventData) {
|
|
149
|
+
queue.async {
|
|
150
|
+
self.invokers = self.invokers.filter { $0.invoke(data) }
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
}
|
package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/MediaItemProperty.swift
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MediaItemProperty.swift
|
|
3
|
+
// SwiftAudio
|
|
4
|
+
//
|
|
5
|
+
// Created by Jørgen Henrichsen on 15/03/2018.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import MediaPlayer
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
Enum representing MPMediaItemProperties.
|
|
14
|
+
Docs for each property is taken from [Apple docs](https://developer.apple.com/documentation/mediaplayer/mpmediaitem/general_media_item_property_keys)
|
|
15
|
+
*/
|
|
16
|
+
public enum MediaItemProperty: NowPlayingInfoKeyValue {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
The performing artist(s) for a media item—which may vary from the primary artist for the album that a media item belongs to.
|
|
20
|
+
|
|
21
|
+
For example, if the album artist is “Joseph Fable,” the artist for one of the songs in the album may be “Joseph Fable featuring Thomas Smithson”. Value is an NSString object.
|
|
22
|
+
*/
|
|
23
|
+
case artist(String?)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
The title (or name) of the media item.
|
|
28
|
+
|
|
29
|
+
This property is unrelated to the MPMediaItemPropertyAlbumTitle property. Value is an NSString object.
|
|
30
|
+
*/
|
|
31
|
+
case title(String?)
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
The title of an album.
|
|
35
|
+
|
|
36
|
+
This property contains the album title, such as “Live On Mars”, as opposed to the title of an individual song on the album, such as “Crater Dance (radio edit)” (which you specify using the MPMediaItemPropertyTitle property). Value is an NSString object.
|
|
37
|
+
*/
|
|
38
|
+
case albumTitle(String?)
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
The playback duration of the media item.
|
|
42
|
+
Value is an NSNumber object representing a duration in seconds as an TimeInterval.
|
|
43
|
+
*/
|
|
44
|
+
case duration(TimeInterval?)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
The artwork image for the media item.
|
|
49
|
+
*/
|
|
50
|
+
case artwork(MPMediaItemArtwork?)
|
|
51
|
+
|
|
52
|
+
public func getKey() -> String {
|
|
53
|
+
switch self {
|
|
54
|
+
|
|
55
|
+
case .artist(_):
|
|
56
|
+
return MPMediaItemPropertyArtist
|
|
57
|
+
|
|
58
|
+
case .title(_):
|
|
59
|
+
return MPMediaItemPropertyTitle
|
|
60
|
+
|
|
61
|
+
case .albumTitle(_):
|
|
62
|
+
return MPMediaItemPropertyAlbumTitle
|
|
63
|
+
|
|
64
|
+
case .duration(_):
|
|
65
|
+
return MPMediaItemPropertyPlaybackDuration
|
|
66
|
+
|
|
67
|
+
case .artwork(_):
|
|
68
|
+
return MPMediaItemPropertyArtwork
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public func getValue() -> Any? {
|
|
74
|
+
switch self {
|
|
75
|
+
|
|
76
|
+
case .artist(let artist):
|
|
77
|
+
return artist
|
|
78
|
+
|
|
79
|
+
case .title(let title):
|
|
80
|
+
return title
|
|
81
|
+
|
|
82
|
+
case .albumTitle(let title):
|
|
83
|
+
return title
|
|
84
|
+
|
|
85
|
+
case .duration(let duration):
|
|
86
|
+
return duration != nil ? NSNumber(floatLiteral: duration!) : nil
|
|
87
|
+
|
|
88
|
+
case .artwork(let artwork):
|
|
89
|
+
return artwork
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoCenter.swift
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NowPlayingInfoCenter.swift
|
|
3
|
+
// SwiftAudio
|
|
4
|
+
//
|
|
5
|
+
// Created by Jørgen Henrichsen on 03/03/2019.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import MediaPlayer
|
|
10
|
+
|
|
11
|
+
public protocol NowPlayingInfoCenter {
|
|
12
|
+
|
|
13
|
+
var nowPlayingInfo: [String: Any]? { get set }
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
extension MPNowPlayingInfoCenter: NowPlayingInfoCenter {}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MediaInfoController.swift
|
|
3
|
+
// SwiftAudio
|
|
4
|
+
//
|
|
5
|
+
// Created by Jørgen Henrichsen on 15/03/2018.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import MediaPlayer
|
|
10
|
+
|
|
11
|
+
public class NowPlayingInfoController: NowPlayingInfoControllerProtocol {
|
|
12
|
+
private var infoQueue: DispatchQueueType = DispatchQueue(
|
|
13
|
+
label: "NowPlayingInfoController.infoQueue",
|
|
14
|
+
attributes: .concurrent
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
private(set) var infoCenter: NowPlayingInfoCenter
|
|
18
|
+
private(set) var info: [String: Any] = [:]
|
|
19
|
+
|
|
20
|
+
public required init() {
|
|
21
|
+
infoCenter = MPNowPlayingInfoCenter.default()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// Used for testing purposes.
|
|
25
|
+
public required init(dispatchQueue: DispatchQueueType, infoCenter: NowPlayingInfoCenter) {
|
|
26
|
+
infoQueue = dispatchQueue
|
|
27
|
+
self.infoCenter = infoCenter
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public required init(infoCenter: NowPlayingInfoCenter = MPNowPlayingInfoCenter.default()) {
|
|
31
|
+
self.infoCenter = infoCenter
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public func set(keyValues: [NowPlayingInfoKeyValue]) {
|
|
35
|
+
infoQueue.async(flags: .barrier) { [weak self] in
|
|
36
|
+
guard let self = self else { return }
|
|
37
|
+
keyValues.forEach {
|
|
38
|
+
(keyValue) in self.info[keyValue.getKey()] = keyValue.getValue()
|
|
39
|
+
}
|
|
40
|
+
self.update()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public func setWithoutUpdate(keyValues: [NowPlayingInfoKeyValue]) {
|
|
45
|
+
infoQueue.async(flags: .barrier) { [weak self] in
|
|
46
|
+
guard let self = self else { return }
|
|
47
|
+
keyValues.forEach {
|
|
48
|
+
(keyValue) in self.info[keyValue.getKey()] = keyValue.getValue()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public func set(keyValue: NowPlayingInfoKeyValue) {
|
|
54
|
+
infoQueue.async(flags: .barrier) { [weak self] in
|
|
55
|
+
guard let self = self else { return }
|
|
56
|
+
self.info[keyValue.getKey()] = keyValue.getValue()
|
|
57
|
+
self.update()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private func update() {
|
|
62
|
+
infoCenter.nowPlayingInfo = info
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public func clear() {
|
|
66
|
+
infoQueue.async(flags: .barrier) { [weak self] in
|
|
67
|
+
guard let self = self else { return }
|
|
68
|
+
self.info = [:]
|
|
69
|
+
self.infoCenter.nowPlayingInfo = nil
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NowPlayingInfoControllerProtocol.swift
|
|
3
|
+
// SwiftAudio
|
|
4
|
+
//
|
|
5
|
+
// Created by Jørgen Henrichsen on 28/02/2019.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import MediaPlayer
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
public protocol NowPlayingInfoControllerProtocol {
|
|
13
|
+
|
|
14
|
+
init()
|
|
15
|
+
|
|
16
|
+
init(infoCenter: NowPlayingInfoCenter)
|
|
17
|
+
|
|
18
|
+
func set(keyValue: NowPlayingInfoKeyValue)
|
|
19
|
+
|
|
20
|
+
func set(keyValues: [NowPlayingInfoKeyValue])
|
|
21
|
+
|
|
22
|
+
func setWithoutUpdate(keyValues: [NowPlayingInfoKeyValue])
|
|
23
|
+
|
|
24
|
+
func clear()
|
|
25
|
+
|
|
26
|
+
}
|