react-native-mp3-player 1.0.0

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.
Files changed (328) hide show
  1. package/LICENSE +205 -0
  2. package/README.md +88 -0
  3. package/android/build.gradle +114 -0
  4. package/android/proguard-rules.txt +0 -0
  5. package/android/src/main/AndroidManifest.xml +27 -0
  6. package/android/src/main/java/com/doublesymmetry/trackplayer/HeadlessJsMediaService.kt +199 -0
  7. package/android/src/main/java/com/doublesymmetry/trackplayer/TrackPlayer.kt +30 -0
  8. package/android/src/main/java/com/doublesymmetry/trackplayer/extensions/AudioPlayerStateExt.kt +19 -0
  9. package/android/src/main/java/com/doublesymmetry/trackplayer/extensions/EnumExtensions.kt +5 -0
  10. package/android/src/main/java/com/doublesymmetry/trackplayer/extensions/NumberExt.kt +13 -0
  11. package/android/src/main/java/com/doublesymmetry/trackplayer/model/MetadataAdapter.kt +227 -0
  12. package/android/src/main/java/com/doublesymmetry/trackplayer/model/NowPlayingMetadata.kt +16 -0
  13. package/android/src/main/java/com/doublesymmetry/trackplayer/model/PlaybackMetadata.kt +203 -0
  14. package/android/src/main/java/com/doublesymmetry/trackplayer/model/State.kt +13 -0
  15. package/android/src/main/java/com/doublesymmetry/trackplayer/model/Track.kt +67 -0
  16. package/android/src/main/java/com/doublesymmetry/trackplayer/model/TrackAudioItem.kt +18 -0
  17. package/android/src/main/java/com/doublesymmetry/trackplayer/model/TrackMetadata.kt +38 -0
  18. package/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicEvents.kt +65 -0
  19. package/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt +775 -0
  20. package/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt +1251 -0
  21. package/android/src/main/java/com/doublesymmetry/trackplayer/utils/AppForegroundTracker.kt +35 -0
  22. package/android/src/main/java/com/doublesymmetry/trackplayer/utils/BundleUtils.kt +147 -0
  23. package/android/src/main/java/com/doublesymmetry/trackplayer/utils/CoilBitmapLoader.kt +64 -0
  24. package/android/src/main/java/com/doublesymmetry/trackplayer/utils/MediaItemBuilder.kt +41 -0
  25. package/android/src/main/java/com/doublesymmetry/trackplayer/utils/RejectionException.kt +11 -0
  26. package/android/src/main/java/com/lovegaoshi/kotlinaudio/event/EventHolder.kt +30 -0
  27. package/android/src/main/java/com/lovegaoshi/kotlinaudio/event/PlayerEventHolder.kt +124 -0
  28. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/AudioContentType.kt +10 -0
  29. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/AudioItem.kt +133 -0
  30. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/AudioItemTransitionReason.kt +33 -0
  31. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/AudioPlayerState.kt +30 -0
  32. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/BufferConfig.kt +8 -0
  33. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/CacheConfig.kt +17 -0
  34. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/Capability.kt +19 -0
  35. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/CustomButton.kt +19 -0
  36. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/FocusChangeData.kt +3 -0
  37. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/MediaSessionCallback.kt +17 -0
  38. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlayWhenReadyChangeData.kt +3 -0
  39. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlaybackEndedReason.kt +5 -0
  40. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlaybackError.kt +6 -0
  41. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlayerConfig.kt +36 -0
  42. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PlayerOptions.kt +39 -0
  43. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/PositionChangedReason.kt +39 -0
  44. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/RepeatMode.kt +16 -0
  45. package/android/src/main/java/com/lovegaoshi/kotlinaudio/models/WakeMode.kt +7 -0
  46. package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/AudioPlayer.kt +689 -0
  47. package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/ForwardingPlayer.java +1124 -0
  48. package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/QueuedAudioPlayer.kt +295 -0
  49. package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/components/Buffer.kt +34 -0
  50. package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/components/Cache.kt +47 -0
  51. package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/components/FocusManager.kt +59 -0
  52. package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/components/MediaFactory.kt +165 -0
  53. package/android/src/main/java/com/lovegaoshi/kotlinaudio/service/MusicService.kt +127 -0
  54. package/android/src/main/java/com/lovegaoshi/kotlinaudio/utils/Utils.kt +113 -0
  55. package/android/src/main/res/drawable/baseline_repeat_24.xml +5 -0
  56. package/android/src/main/res/drawable/baseline_repeat_one_24.xml +5 -0
  57. package/android/src/main/res/drawable/forward.xml +5 -0
  58. package/android/src/main/res/drawable/heart_24px.xml +5 -0
  59. package/android/src/main/res/drawable/hearte_24px.xml +5 -0
  60. package/android/src/main/res/drawable/ifl_24px.xml +5 -0
  61. package/android/src/main/res/drawable/rewind.xml +5 -0
  62. package/android/src/main/res/drawable/shuffle_24px.xml +5 -0
  63. package/android/src/main/res/values/strings.xml +5 -0
  64. package/android/src/main/res/xml/automotive_app_desc.xml +3 -0
  65. package/ios/Example/SwiftAudio/Assets.xcassets/22AMI.imageset/22AMillion.jpg +0 -0
  66. package/ios/Example/SwiftAudio/Assets.xcassets/22AMI.imageset/Contents.json +21 -0
  67. package/ios/Example/SwiftAudio/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  68. package/ios/Example/SwiftAudio/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
  69. package/ios/Example/SwiftAudio/Assets.xcassets/Contents.json +6 -0
  70. package/ios/Example/SwiftAudio/Assets.xcassets/cover.imageset/Contents.json +21 -0
  71. package/ios/Example/SwiftAudio/Assets.xcassets/cover.imageset/cover.jpg +0 -0
  72. package/ios/Example/SwiftAudio/AudioController.swift +46 -0
  73. package/ios/Example/SwiftAudio/Extensions.swift +22 -0
  74. package/ios/Example/SwiftAudio/PlayerView.swift +172 -0
  75. package/ios/Example/SwiftAudio/PlayerViewModel.swift +120 -0
  76. package/ios/Example/SwiftAudio/Preview Content/Preview Assets.xcassets/Contents.json +6 -0
  77. package/ios/Example/SwiftAudio/QueueView.swift +65 -0
  78. package/ios/Example/SwiftAudio/SwiftAudio.entitlements +12 -0
  79. package/ios/Example/SwiftAudio/SwiftAudioApp.swift +17 -0
  80. package/ios/Example/SwiftAudio.xcodeproj/project.pbxproj +412 -0
  81. package/ios/Example/SwiftAudio.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  82. package/ios/Example/SwiftAudio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  83. package/ios/RNTrackPlayer/Models/Capabilities.swift +52 -0
  84. package/ios/RNTrackPlayer/Models/MediaURL.swift +38 -0
  85. package/ios/RNTrackPlayer/Models/MetadataAdapter.swift +147 -0
  86. package/ios/RNTrackPlayer/Models/PitchAlgorithms.swift +13 -0
  87. package/ios/RNTrackPlayer/Models/SessionCategories.swift +106 -0
  88. package/ios/RNTrackPlayer/Models/State.swift +26 -0
  89. package/ios/RNTrackPlayer/Models/Track.swift +140 -0
  90. package/ios/RNTrackPlayer/RNTrackPlayer.swift +941 -0
  91. package/ios/RNTrackPlayer/Support/RNTrackPlayer-Bridging-Header.h +7 -0
  92. package/ios/RNTrackPlayer/TrackPlayer.h +14 -0
  93. package/ios/RNTrackPlayer/TrackPlayer.mm +246 -0
  94. package/ios/RNTrackPlayer/Utils/EventType.swift +44 -0
  95. package/ios/RNTrackPlayer/Utils/Metadata.swift +60 -0
  96. package/ios/SwiftAudioEx/Package.swift +20 -0
  97. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AVPlayerWrapper/AVPlayerWrapper.swift +521 -0
  98. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AVPlayerWrapper/AVPlayerWrapperDelegate.swift +27 -0
  99. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AVPlayerWrapper/AVPlayerWrapperProtocol.swift +69 -0
  100. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AVPlayerWrapper/AVPlayerWrapperState.swift +43 -0
  101. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioItem.swift +158 -0
  102. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioPlayer.swift +459 -0
  103. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioPlayerError.swift +26 -0
  104. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioSessionController/AudioSession.swift +33 -0
  105. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioSessionController/AudioSessionController.swift +135 -0
  106. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/AudioTap.swift +99 -0
  107. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Event.swift +155 -0
  108. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/MediaItemProperty.swift +95 -0
  109. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoCenter.swift +17 -0
  110. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoController.swift +73 -0
  111. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoControllerProtocol.swift +26 -0
  112. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoKeyValue.swift +14 -0
  113. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/NowPlayingInfoController/NowPlayingInfoProperty.swift +234 -0
  114. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Observer/AVPlayerItemNotificationObserver.swift +102 -0
  115. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Observer/AVPlayerItemObserver.swift +136 -0
  116. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Observer/AVPlayerObserver.swift +120 -0
  117. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Observer/AVPlayerTimeObserver.swift +112 -0
  118. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/QueueManager.swift +356 -0
  119. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/QueuedAudioPlayer.swift +236 -0
  120. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/RemoteCommandController/RemoteCommand.swift +170 -0
  121. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/RemoteCommandController/RemoteCommandController.swift +206 -0
  122. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/RepeatMode.swift +15 -0
  123. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/TimeEventFrequency.swift +26 -0
  124. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/Utils/DispatchQueueType.swift +18 -0
  125. package/ios/SwiftAudioEx/Sources/SwiftAudioEx/WaveformAudioTap.swift +159 -0
  126. package/lib/specs/NativeTrackPlayer.d.ts +129 -0
  127. package/lib/specs/NativeTrackPlayer.js +4 -0
  128. package/lib/src/constants/AndroidAudioContentType.d.ts +35 -0
  129. package/lib/src/constants/AndroidAudioContentType.js +36 -0
  130. package/lib/src/constants/AndroidAutoContentStyle.d.ts +10 -0
  131. package/lib/src/constants/AndroidAutoContentStyle.js +11 -0
  132. package/lib/src/constants/AppKilledPlaybackBehavior.d.ts +17 -0
  133. package/lib/src/constants/AppKilledPlaybackBehavior.js +18 -0
  134. package/lib/src/constants/Capability.d.ts +17 -0
  135. package/lib/src/constants/Capability.js +19 -0
  136. package/lib/src/constants/Event.d.ts +163 -0
  137. package/lib/src/constants/Event.js +164 -0
  138. package/lib/src/constants/IOSCategory.d.ts +36 -0
  139. package/lib/src/constants/IOSCategory.js +37 -0
  140. package/lib/src/constants/IOSCategoryMode.d.ts +47 -0
  141. package/lib/src/constants/IOSCategoryMode.js +48 -0
  142. package/lib/src/constants/IOSCategoryOptions.d.ts +44 -0
  143. package/lib/src/constants/IOSCategoryOptions.js +45 -0
  144. package/lib/src/constants/MediaItemPlayable.d.ts +4 -0
  145. package/lib/src/constants/MediaItemPlayable.js +5 -0
  146. package/lib/src/constants/PitchAlgorithm.d.ts +14 -0
  147. package/lib/src/constants/PitchAlgorithm.js +16 -0
  148. package/lib/src/constants/RatingType.d.ts +8 -0
  149. package/lib/src/constants/RatingType.js +10 -0
  150. package/lib/src/constants/RepeatMode.d.ts +8 -0
  151. package/lib/src/constants/RepeatMode.js +10 -0
  152. package/lib/src/constants/State.d.ts +34 -0
  153. package/lib/src/constants/State.js +35 -0
  154. package/lib/src/constants/TrackType.d.ts +6 -0
  155. package/lib/src/constants/TrackType.js +7 -0
  156. package/lib/src/constants/index.d.ts +14 -0
  157. package/lib/src/constants/index.js +14 -0
  158. package/lib/src/hooks/index.d.ts +6 -0
  159. package/lib/src/hooks/index.js +6 -0
  160. package/lib/src/hooks/useActiveTrack.d.ts +2 -0
  161. package/lib/src/hooks/useActiveTrack.js +28 -0
  162. package/lib/src/hooks/useAppIsInBackground.d.ts +1 -0
  163. package/lib/src/hooks/useAppIsInBackground.js +16 -0
  164. package/lib/src/hooks/useIsPlaying.d.ts +35 -0
  165. package/lib/src/hooks/useIsPlaying.js +50 -0
  166. package/lib/src/hooks/usePlayWhenReady.d.ts +1 -0
  167. package/lib/src/hooks/usePlayWhenReady.js +27 -0
  168. package/lib/src/hooks/usePlaybackState.d.ts +10 -0
  169. package/lib/src/hooks/usePlaybackState.js +35 -0
  170. package/lib/src/hooks/useProgress.d.ts +7 -0
  171. package/lib/src/hooks/useProgress.js +55 -0
  172. package/lib/src/hooks/useTrackPlayerEvents.d.ts +8 -0
  173. package/lib/src/hooks/useTrackPlayerEvents.js +30 -0
  174. package/lib/src/index.d.ts +5 -0
  175. package/lib/src/index.js +5 -0
  176. package/lib/src/interfaces/AndroidAutoBrowseTree.d.ts +5 -0
  177. package/lib/src/interfaces/AndroidAutoBrowseTree.js +1 -0
  178. package/lib/src/interfaces/AndroidOptions.d.ts +41 -0
  179. package/lib/src/interfaces/AndroidOptions.js +1 -0
  180. package/lib/src/interfaces/CustomButtons.d.ts +5 -0
  181. package/lib/src/interfaces/CustomButtons.js +1 -0
  182. package/lib/src/interfaces/FeedbackOptions.d.ts +6 -0
  183. package/lib/src/interfaces/FeedbackOptions.js +1 -0
  184. package/lib/src/interfaces/MediaItem.d.ts +18 -0
  185. package/lib/src/interfaces/MediaItem.js +1 -0
  186. package/lib/src/interfaces/MetadataOptions.d.ts +3 -0
  187. package/lib/src/interfaces/MetadataOptions.js +1 -0
  188. package/lib/src/interfaces/NowPlayingMetadata.d.ts +4 -0
  189. package/lib/src/interfaces/NowPlayingMetadata.js +1 -0
  190. package/lib/src/interfaces/PlaybackState.d.ts +8 -0
  191. package/lib/src/interfaces/PlaybackState.js +1 -0
  192. package/lib/src/interfaces/PlayerOptions.d.ts +127 -0
  193. package/lib/src/interfaces/PlayerOptions.js +1 -0
  194. package/lib/src/interfaces/Progress.d.ts +15 -0
  195. package/lib/src/interfaces/Progress.js +1 -0
  196. package/lib/src/interfaces/ResourceObject.d.ts +1 -0
  197. package/lib/src/interfaces/ResourceObject.js +1 -0
  198. package/lib/src/interfaces/ServiceHandler.d.ts +1 -0
  199. package/lib/src/interfaces/ServiceHandler.js +1 -0
  200. package/lib/src/interfaces/Track.d.ts +21 -0
  201. package/lib/src/interfaces/Track.js +1 -0
  202. package/lib/src/interfaces/TrackMetadataBase.d.ts +28 -0
  203. package/lib/src/interfaces/TrackMetadataBase.js +1 -0
  204. package/lib/src/interfaces/UpdateOptions.d.ts +52 -0
  205. package/lib/src/interfaces/UpdateOptions.js +1 -0
  206. package/lib/src/interfaces/events/AudioMetadataReceivedEvent.d.ts +33 -0
  207. package/lib/src/interfaces/events/AudioMetadataReceivedEvent.js +1 -0
  208. package/lib/src/interfaces/events/ControllerConnectedEvent.d.ts +8 -0
  209. package/lib/src/interfaces/events/ControllerConnectedEvent.js +1 -0
  210. package/lib/src/interfaces/events/EventPayloadByEvent.d.ts +73 -0
  211. package/lib/src/interfaces/events/EventPayloadByEvent.js +1 -0
  212. package/lib/src/interfaces/events/PlaybackActiveTrackChangedEvent.d.ts +24 -0
  213. package/lib/src/interfaces/events/PlaybackActiveTrackChangedEvent.js +1 -0
  214. package/lib/src/interfaces/events/PlaybackAnimatedVolumeChangedEvent.d.ts +4 -0
  215. package/lib/src/interfaces/events/PlaybackAnimatedVolumeChangedEvent.js +1 -0
  216. package/lib/src/interfaces/events/PlaybackErrorEvent.d.ts +6 -0
  217. package/lib/src/interfaces/events/PlaybackErrorEvent.js +1 -0
  218. package/lib/src/interfaces/events/PlaybackMetadataReceivedEvent.d.ts +16 -0
  219. package/lib/src/interfaces/events/PlaybackMetadataReceivedEvent.js +1 -0
  220. package/lib/src/interfaces/events/PlaybackPlayWhenReadyChangedEvent.d.ts +4 -0
  221. package/lib/src/interfaces/events/PlaybackPlayWhenReadyChangedEvent.js +1 -0
  222. package/lib/src/interfaces/events/PlaybackProgressUpdatedEvent.d.ts +4 -0
  223. package/lib/src/interfaces/events/PlaybackProgressUpdatedEvent.js +1 -0
  224. package/lib/src/interfaces/events/PlaybackQueueEndedEvent.d.ts +9 -0
  225. package/lib/src/interfaces/events/PlaybackQueueEndedEvent.js +1 -0
  226. package/lib/src/interfaces/events/PlaybackResumeEvent.d.ts +3 -0
  227. package/lib/src/interfaces/events/PlaybackResumeEvent.js +1 -0
  228. package/lib/src/interfaces/events/PlaybackTrackChangedEvent.d.ts +11 -0
  229. package/lib/src/interfaces/events/PlaybackTrackChangedEvent.js +1 -0
  230. package/lib/src/interfaces/events/PlayerErrorEvent.d.ts +6 -0
  231. package/lib/src/interfaces/events/PlayerErrorEvent.js +1 -0
  232. package/lib/src/interfaces/events/RemoteBrowseEvent.d.ts +4 -0
  233. package/lib/src/interfaces/events/RemoteBrowseEvent.js +1 -0
  234. package/lib/src/interfaces/events/RemoteCustomActionEvent.d.ts +7 -0
  235. package/lib/src/interfaces/events/RemoteCustomActionEvent.js +1 -0
  236. package/lib/src/interfaces/events/RemoteDuckEvent.d.ts +13 -0
  237. package/lib/src/interfaces/events/RemoteDuckEvent.js +1 -0
  238. package/lib/src/interfaces/events/RemoteJumpBackwardEvent.d.ts +8 -0
  239. package/lib/src/interfaces/events/RemoteJumpBackwardEvent.js +1 -0
  240. package/lib/src/interfaces/events/RemoteJumpForwardEvent.d.ts +8 -0
  241. package/lib/src/interfaces/events/RemoteJumpForwardEvent.js +1 -0
  242. package/lib/src/interfaces/events/RemotePlayIdEvent.d.ts +4 -0
  243. package/lib/src/interfaces/events/RemotePlayIdEvent.js +1 -0
  244. package/lib/src/interfaces/events/RemotePlaySearchEvent.d.ts +9 -0
  245. package/lib/src/interfaces/events/RemotePlaySearchEvent.js +1 -0
  246. package/lib/src/interfaces/events/RemoteSeekEvent.d.ts +4 -0
  247. package/lib/src/interfaces/events/RemoteSeekEvent.js +1 -0
  248. package/lib/src/interfaces/events/RemoteSetRatingEvent.d.ts +4 -0
  249. package/lib/src/interfaces/events/RemoteSetRatingEvent.js +1 -0
  250. package/lib/src/interfaces/events/RemoteSkipEvent.d.ts +3 -0
  251. package/lib/src/interfaces/events/RemoteSkipEvent.js +1 -0
  252. package/lib/src/interfaces/events/index.d.ts +18 -0
  253. package/lib/src/interfaces/events/index.js +18 -0
  254. package/lib/src/interfaces/index.d.ts +15 -0
  255. package/lib/src/interfaces/index.js +15 -0
  256. package/lib/src/resolveAssetSource.d.ts +2 -0
  257. package/lib/src/resolveAssetSource.js +3 -0
  258. package/lib/src/trackPlayer.d.ts +347 -0
  259. package/lib/src/trackPlayer.js +592 -0
  260. package/package.json +94 -0
  261. package/react-native-mp3-player.podspec +22 -0
  262. package/specs/NativeTrackPlayer.ts +148 -0
  263. package/src/constants/AndroidAudioContentType.ts +35 -0
  264. package/src/constants/AndroidAutoContentStyle.ts +10 -0
  265. package/src/constants/AppKilledPlaybackBehavior.ts +19 -0
  266. package/src/constants/Capability.ts +19 -0
  267. package/src/constants/Event.ts +164 -0
  268. package/src/constants/IOSCategory.ts +36 -0
  269. package/src/constants/IOSCategoryMode.ts +47 -0
  270. package/src/constants/IOSCategoryOptions.ts +44 -0
  271. package/src/constants/MediaItemPlayable.ts +4 -0
  272. package/src/constants/PitchAlgorithm.ts +16 -0
  273. package/src/constants/RatingType.ts +10 -0
  274. package/src/constants/RepeatMode.ts +10 -0
  275. package/src/constants/State.ts +34 -0
  276. package/src/constants/TrackType.ts +6 -0
  277. package/src/constants/index.ts +14 -0
  278. package/src/hooks/index.ts +6 -0
  279. package/src/hooks/useActiveTrack.ts +36 -0
  280. package/src/hooks/useAppIsInBackground.ts +20 -0
  281. package/src/hooks/useIsPlaying.ts +56 -0
  282. package/src/hooks/usePlayWhenReady.ts +37 -0
  283. package/src/hooks/usePlaybackState.ts +45 -0
  284. package/src/hooks/useProgress.ts +64 -0
  285. package/src/hooks/useTrackPlayerEvents.ts +48 -0
  286. package/src/index.ts +7 -0
  287. package/src/interfaces/AndroidAutoBrowseTree.ts +6 -0
  288. package/src/interfaces/AndroidOptions.ts +48 -0
  289. package/src/interfaces/CustomButtons.ts +6 -0
  290. package/src/interfaces/FeedbackOptions.ts +7 -0
  291. package/src/interfaces/MediaItem.ts +19 -0
  292. package/src/interfaces/MetadataOptions.ts +4 -0
  293. package/src/interfaces/NowPlayingMetadata.ts +5 -0
  294. package/src/interfaces/PlaybackState.ts +11 -0
  295. package/src/interfaces/PlayerOptions.ts +133 -0
  296. package/src/interfaces/Progress.ts +15 -0
  297. package/src/interfaces/ResourceObject.ts +1 -0
  298. package/src/interfaces/ServiceHandler.ts +1 -0
  299. package/src/interfaces/Track.ts +23 -0
  300. package/src/interfaces/TrackMetadataBase.ts +29 -0
  301. package/src/interfaces/UpdateOptions.ts +59 -0
  302. package/src/interfaces/events/AudioMetadataReceivedEvent.ts +37 -0
  303. package/src/interfaces/events/ControllerConnectedEvent.ts +9 -0
  304. package/src/interfaces/events/EventPayloadByEvent.ts +76 -0
  305. package/src/interfaces/events/PlaybackActiveTrackChangedEvent.ts +29 -0
  306. package/src/interfaces/events/PlaybackAnimatedVolumeChangedEvent.ts +4 -0
  307. package/src/interfaces/events/PlaybackErrorEvent.ts +6 -0
  308. package/src/interfaces/events/PlaybackMetadataReceivedEvent.ts +16 -0
  309. package/src/interfaces/events/PlaybackPlayWhenReadyChangedEvent.ts +4 -0
  310. package/src/interfaces/events/PlaybackProgressUpdatedEvent.ts +5 -0
  311. package/src/interfaces/events/PlaybackQueueEndedEvent.ts +9 -0
  312. package/src/interfaces/events/PlaybackResumeEvent.ts +5 -0
  313. package/src/interfaces/events/PlaybackTrackChangedEvent.ts +11 -0
  314. package/src/interfaces/events/PlayerErrorEvent.ts +6 -0
  315. package/src/interfaces/events/RemoteBrowseEvent.ts +4 -0
  316. package/src/interfaces/events/RemoteCustomActionEvent.ts +7 -0
  317. package/src/interfaces/events/RemoteDuckEvent.ts +13 -0
  318. package/src/interfaces/events/RemoteJumpBackwardEvent.ts +8 -0
  319. package/src/interfaces/events/RemoteJumpForwardEvent.ts +8 -0
  320. package/src/interfaces/events/RemotePlayIdEvent.ts +4 -0
  321. package/src/interfaces/events/RemotePlaySearchEvent.ts +21 -0
  322. package/src/interfaces/events/RemoteSeekEvent.ts +4 -0
  323. package/src/interfaces/events/RemoteSetRatingEvent.ts +5 -0
  324. package/src/interfaces/events/RemoteSkipEvent.ts +3 -0
  325. package/src/interfaces/events/index.ts +18 -0
  326. package/src/interfaces/index.ts +15 -0
  327. package/src/resolveAssetSource.ts +3 -0
  328. package/src/trackPlayer.ts +768 -0
@@ -0,0 +1,36 @@
1
+ export declare enum IOSCategory {
2
+ /**
3
+ * The category for playing recorded music or other sounds that are central
4
+ * to the successful use of your app.
5
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616509-playback
6
+ **/
7
+ Playback = "playback",
8
+ /**
9
+ * The category for recording (input) and playback (output) of audio, such as
10
+ * for a Voice over Internet Protocol (VoIP) app.
11
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616568-playandrecord
12
+ **/
13
+ PlayAndRecord = "playAndRecord",
14
+ /**
15
+ * The category for routing distinct streams of audio data to different
16
+ * output devices at the same time.
17
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616484-multiroute
18
+ **/
19
+ MultiRoute = "multiRoute",
20
+ /**
21
+ * The category for an app in which sound playback is nonprimary — that is,
22
+ * your app also works with the sound turned off.
23
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616560-ambient
24
+ **/
25
+ Ambient = "ambient",
26
+ /**
27
+ * The default audio session category.
28
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616488-soloambient
29
+ **/
30
+ SoloAmbient = "soloAmbient",
31
+ /**
32
+ * The category for recording audio while also silencing playback audio.
33
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616451-record
34
+ **/
35
+ Record = "record"
36
+ }
@@ -0,0 +1,37 @@
1
+ export var IOSCategory;
2
+ (function (IOSCategory) {
3
+ /**
4
+ * The category for playing recorded music or other sounds that are central
5
+ * to the successful use of your app.
6
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616509-playback
7
+ **/
8
+ IOSCategory["Playback"] = "playback";
9
+ /**
10
+ * The category for recording (input) and playback (output) of audio, such as
11
+ * for a Voice over Internet Protocol (VoIP) app.
12
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616568-playandrecord
13
+ **/
14
+ IOSCategory["PlayAndRecord"] = "playAndRecord";
15
+ /**
16
+ * The category for routing distinct streams of audio data to different
17
+ * output devices at the same time.
18
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616484-multiroute
19
+ **/
20
+ IOSCategory["MultiRoute"] = "multiRoute";
21
+ /**
22
+ * The category for an app in which sound playback is nonprimary — that is,
23
+ * your app also works with the sound turned off.
24
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616560-ambient
25
+ **/
26
+ IOSCategory["Ambient"] = "ambient";
27
+ /**
28
+ * The default audio session category.
29
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616488-soloambient
30
+ **/
31
+ IOSCategory["SoloAmbient"] = "soloAmbient";
32
+ /**
33
+ * The category for recording audio while also silencing playback audio.
34
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616451-record
35
+ **/
36
+ IOSCategory["Record"] = "record";
37
+ })(IOSCategory || (IOSCategory = {}));
@@ -0,0 +1,47 @@
1
+ export declare enum IOSCategoryMode {
2
+ /**
3
+ * The default audio session mode.
4
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616579-default
5
+ **/
6
+ Default = "default",
7
+ /**
8
+ * A mode that the GameKit framework sets on behalf of an application that
9
+ * uses GameKit’s voice chat service.
10
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616511-gamechat
11
+ **/
12
+ GameChat = "gameChat",
13
+ /**
14
+ * A mode that indicates that your app is performing measurement of audio
15
+ * input or output.
16
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616608-measurement
17
+ **/
18
+ Measurement = "measurement",
19
+ /** A mode that indicates that your app is playing back movie content.
20
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616623-movieplayback
21
+ **/
22
+ MoviePlayback = "moviePlayback",
23
+ /** A mode used for continuous spoken audio to pause the audio when another
24
+ * app plays a short audio prompt. See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616510-spokenaudio */
25
+ SpokenAudio = "spokenAudio",
26
+ /**
27
+ * A mode that indicates that your app is engaging in online video conferencing.
28
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616590-videochat
29
+ **/
30
+ VideoChat = "videoChat",
31
+ /**
32
+ * A mode that indicates that your app is recording a movie.
33
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616535-videorecording
34
+ **/
35
+ VideoRecording = "videoRecording",
36
+ /**
37
+ * A mode that indicates that your app is performing two-way voice communication,
38
+ * such as using Voice over Internet Protocol (VoIP).
39
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616455-voicechat
40
+ **/
41
+ VoiceChat = "voiceChat",
42
+ /**
43
+ * A mode that indicates that your app plays audio using text-to-speech.
44
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/2962803-voiceprompt
45
+ **/
46
+ VoicePrompt = "voicePrompt"
47
+ }
@@ -0,0 +1,48 @@
1
+ export var IOSCategoryMode;
2
+ (function (IOSCategoryMode) {
3
+ /**
4
+ * The default audio session mode.
5
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616579-default
6
+ **/
7
+ IOSCategoryMode["Default"] = "default";
8
+ /**
9
+ * A mode that the GameKit framework sets on behalf of an application that
10
+ * uses GameKit’s voice chat service.
11
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616511-gamechat
12
+ **/
13
+ IOSCategoryMode["GameChat"] = "gameChat";
14
+ /**
15
+ * A mode that indicates that your app is performing measurement of audio
16
+ * input or output.
17
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616608-measurement
18
+ **/
19
+ IOSCategoryMode["Measurement"] = "measurement";
20
+ /** A mode that indicates that your app is playing back movie content.
21
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616623-movieplayback
22
+ **/
23
+ IOSCategoryMode["MoviePlayback"] = "moviePlayback";
24
+ /** A mode used for continuous spoken audio to pause the audio when another
25
+ * app plays a short audio prompt. See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616510-spokenaudio */
26
+ IOSCategoryMode["SpokenAudio"] = "spokenAudio";
27
+ /**
28
+ * A mode that indicates that your app is engaging in online video conferencing.
29
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616590-videochat
30
+ **/
31
+ IOSCategoryMode["VideoChat"] = "videoChat";
32
+ /**
33
+ * A mode that indicates that your app is recording a movie.
34
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616535-videorecording
35
+ **/
36
+ IOSCategoryMode["VideoRecording"] = "videoRecording";
37
+ /**
38
+ * A mode that indicates that your app is performing two-way voice communication,
39
+ * such as using Voice over Internet Protocol (VoIP).
40
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616455-voicechat
41
+ **/
42
+ IOSCategoryMode["VoiceChat"] = "voiceChat";
43
+ /**
44
+ * A mode that indicates that your app plays audio using text-to-speech.
45
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/2962803-voiceprompt
46
+ **/
47
+ IOSCategoryMode["VoicePrompt"] = "voicePrompt";
48
+ })(IOSCategoryMode || (IOSCategoryMode = {}));
@@ -0,0 +1,44 @@
1
+ export declare enum IOSCategoryOptions {
2
+ /**
3
+ * An option that indicates whether audio from this session mixes with audio
4
+ * from active sessions in other audio apps.
5
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616611-mixwithothers
6
+ **/
7
+ MixWithOthers = "mixWithOthers",
8
+ /**
9
+ * An option that reduces the volume of other audio sessions while audio from
10
+ * this session plays.
11
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616618-duckothers
12
+ **/
13
+ DuckOthers = "duckOthers",
14
+ /**
15
+ * An option that determines whether to pause spoken audio content from other
16
+ * sessions when your app plays its audio.
17
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616534-interruptspokenaudioandmixwithot
18
+ **/
19
+ InterruptSpokenAudioAndMixWithOthers = "interruptSpokenAudioAndMixWithOthers",
20
+ /**
21
+ * An option that determines whether Bluetooth hands-free devices appear as
22
+ * available input routes.
23
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616518-allowbluetooth
24
+ **/
25
+ AllowBluetooth = "allowBluetooth",
26
+ /**
27
+ * An option that determines whether you can stream audio from this session
28
+ * to Bluetooth devices that support the Advanced Audio Distribution Profile (A2DP).
29
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1771735-allowbluetootha2dp
30
+ **/
31
+ AllowBluetoothA2DP = "allowBluetoothA2DP",
32
+ /**
33
+ * An option that determines whether you can stream audio from this session
34
+ * to AirPlay devices.
35
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1771736-allowairplay
36
+ **/
37
+ AllowAirPlay = "allowAirPlay",
38
+ /**
39
+ * An option that determines whether audio from the session defaults to the
40
+ * built-in speaker instead of the receiver.
41
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616462-defaulttospeaker
42
+ **/
43
+ DefaultToSpeaker = "defaultToSpeaker"
44
+ }
@@ -0,0 +1,45 @@
1
+ export var IOSCategoryOptions;
2
+ (function (IOSCategoryOptions) {
3
+ /**
4
+ * An option that indicates whether audio from this session mixes with audio
5
+ * from active sessions in other audio apps.
6
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616611-mixwithothers
7
+ **/
8
+ IOSCategoryOptions["MixWithOthers"] = "mixWithOthers";
9
+ /**
10
+ * An option that reduces the volume of other audio sessions while audio from
11
+ * this session plays.
12
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616618-duckothers
13
+ **/
14
+ IOSCategoryOptions["DuckOthers"] = "duckOthers";
15
+ /**
16
+ * An option that determines whether to pause spoken audio content from other
17
+ * sessions when your app plays its audio.
18
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616534-interruptspokenaudioandmixwithot
19
+ **/
20
+ IOSCategoryOptions["InterruptSpokenAudioAndMixWithOthers"] = "interruptSpokenAudioAndMixWithOthers";
21
+ /**
22
+ * An option that determines whether Bluetooth hands-free devices appear as
23
+ * available input routes.
24
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616518-allowbluetooth
25
+ **/
26
+ IOSCategoryOptions["AllowBluetooth"] = "allowBluetooth";
27
+ /**
28
+ * An option that determines whether you can stream audio from this session
29
+ * to Bluetooth devices that support the Advanced Audio Distribution Profile (A2DP).
30
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1771735-allowbluetootha2dp
31
+ **/
32
+ IOSCategoryOptions["AllowBluetoothA2DP"] = "allowBluetoothA2DP";
33
+ /**
34
+ * An option that determines whether you can stream audio from this session
35
+ * to AirPlay devices.
36
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1771736-allowairplay
37
+ **/
38
+ IOSCategoryOptions["AllowAirPlay"] = "allowAirPlay";
39
+ /**
40
+ * An option that determines whether audio from the session defaults to the
41
+ * built-in speaker instead of the receiver.
42
+ * See https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616462-defaulttospeaker
43
+ **/
44
+ IOSCategoryOptions["DefaultToSpeaker"] = "defaultToSpeaker";
45
+ })(IOSCategoryOptions || (IOSCategoryOptions = {}));
@@ -0,0 +1,4 @@
1
+ export declare enum MediaItemPlayable {
2
+ MediaPlayable = "0",
3
+ MediaBrowsable = "1"
4
+ }
@@ -0,0 +1,5 @@
1
+ export var MediaItemPlayable;
2
+ (function (MediaItemPlayable) {
3
+ MediaItemPlayable["MediaPlayable"] = "0";
4
+ MediaItemPlayable["MediaBrowsable"] = "1";
5
+ })(MediaItemPlayable || (MediaItemPlayable = {}));
@@ -0,0 +1,14 @@
1
+ export declare enum PitchAlgorithm {
2
+ /**
3
+ * A high-quality time pitch algorithm that doesn’t perform pitch correction.
4
+ * */
5
+ Linear,
6
+ /**
7
+ * A highest-quality time pitch algorithm that’s suitable for music.
8
+ **/
9
+ Music,
10
+ /**
11
+ * A modest quality time pitch algorithm that’s suitable for voice.
12
+ **/
13
+ Voice
14
+ }
@@ -0,0 +1,16 @@
1
+ import { Constants as TrackPlayer } from '../../specs/NativeTrackPlayer';
2
+ export var PitchAlgorithm;
3
+ (function (PitchAlgorithm) {
4
+ /**
5
+ * A high-quality time pitch algorithm that doesn’t perform pitch correction.
6
+ * */
7
+ PitchAlgorithm[PitchAlgorithm["Linear"] = TrackPlayer.PITCH_ALGORITHM_LINEAR] = "Linear";
8
+ /**
9
+ * A highest-quality time pitch algorithm that’s suitable for music.
10
+ **/
11
+ PitchAlgorithm[PitchAlgorithm["Music"] = TrackPlayer.PITCH_ALGORITHM_MUSIC] = "Music";
12
+ /**
13
+ * A modest quality time pitch algorithm that’s suitable for voice.
14
+ **/
15
+ PitchAlgorithm[PitchAlgorithm["Voice"] = TrackPlayer.PITCH_ALGORITHM_VOICE] = "Voice";
16
+ })(PitchAlgorithm || (PitchAlgorithm = {}));
@@ -0,0 +1,8 @@
1
+ export declare enum RatingType {
2
+ Heart,
3
+ ThumbsUpDown,
4
+ ThreeStars,
5
+ FourStars,
6
+ FiveStars,
7
+ Percentage
8
+ }
@@ -0,0 +1,10 @@
1
+ import { Constants as TrackPlayer } from '../../specs/NativeTrackPlayer';
2
+ export var RatingType;
3
+ (function (RatingType) {
4
+ RatingType[RatingType["Heart"] = TrackPlayer.RATING_HEART] = "Heart";
5
+ RatingType[RatingType["ThumbsUpDown"] = TrackPlayer.RATING_THUMBS_UP_DOWN] = "ThumbsUpDown";
6
+ RatingType[RatingType["ThreeStars"] = TrackPlayer.RATING_3_STARS] = "ThreeStars";
7
+ RatingType[RatingType["FourStars"] = TrackPlayer.RATING_4_STARS] = "FourStars";
8
+ RatingType[RatingType["FiveStars"] = TrackPlayer.RATING_5_STARS] = "FiveStars";
9
+ RatingType[RatingType["Percentage"] = TrackPlayer.RATING_PERCENTAGE] = "Percentage";
10
+ })(RatingType || (RatingType = {}));
@@ -0,0 +1,8 @@
1
+ export declare enum RepeatMode {
2
+ /** Playback stops when the last track in the queue has finished playing. */
3
+ Off,
4
+ /** Repeats the current track infinitely during ongoing playback. */
5
+ Track,
6
+ /** Repeats the entire queue infinitely. */
7
+ Queue
8
+ }
@@ -0,0 +1,10 @@
1
+ import { Constants as TrackPlayer } from '../../specs/NativeTrackPlayer';
2
+ export var RepeatMode;
3
+ (function (RepeatMode) {
4
+ /** Playback stops when the last track in the queue has finished playing. */
5
+ RepeatMode[RepeatMode["Off"] = TrackPlayer.REPEAT_OFF] = "Off";
6
+ /** Repeats the current track infinitely during ongoing playback. */
7
+ RepeatMode[RepeatMode["Track"] = TrackPlayer.REPEAT_TRACK] = "Track";
8
+ /** Repeats the entire queue infinitely. */
9
+ RepeatMode[RepeatMode["Queue"] = TrackPlayer.REPEAT_QUEUE] = "Queue";
10
+ })(RepeatMode || (RepeatMode = {}));
@@ -0,0 +1,34 @@
1
+ export declare enum State {
2
+ /** Indicates that no media is currently loaded */
3
+ None = "none",
4
+ /** Indicates that the player is paused, but ready to start playing */
5
+ Ready = "ready",
6
+ /** Indicates that the player is currently playing */
7
+ Playing = "playing",
8
+ /** Indicates that the player is currently paused */
9
+ Paused = "paused",
10
+ /** Indicates that the player is currently stopped */
11
+ Stopped = "stopped",
12
+ /** Indicates that the initial load of the item is occurring. */
13
+ Loading = "loading",
14
+ /**
15
+ * @deprecated Use `State.Loading` instead.
16
+ **/
17
+ Connecting = "loading",
18
+ /**
19
+ * Indicates that the player is currently loading more data before it can
20
+ * continue playing or is ready to start playing.
21
+ */
22
+ Buffering = "buffering",
23
+ /**
24
+ * Indicates that playback of the current item failed. Call `TrackPlayer.getError()`
25
+ * to get more information on the type of error that occurred.
26
+ * Call `TrackPlayer.retry()` or `TrackPlayer.play()` to try to play the item
27
+ * again.
28
+ */
29
+ Error = "error",
30
+ /**
31
+ * Indicates that playback stopped due to the end of the queue being reached.
32
+ */
33
+ Ended = "ended"
34
+ }
@@ -0,0 +1,35 @@
1
+ export var State;
2
+ (function (State) {
3
+ /** Indicates that no media is currently loaded */
4
+ State["None"] = "none";
5
+ /** Indicates that the player is paused, but ready to start playing */
6
+ State["Ready"] = "ready";
7
+ /** Indicates that the player is currently playing */
8
+ State["Playing"] = "playing";
9
+ /** Indicates that the player is currently paused */
10
+ State["Paused"] = "paused";
11
+ /** Indicates that the player is currently stopped */
12
+ State["Stopped"] = "stopped";
13
+ /** Indicates that the initial load of the item is occurring. */
14
+ State["Loading"] = "loading";
15
+ /**
16
+ * @deprecated Use `State.Loading` instead.
17
+ **/
18
+ State["Connecting"] = "loading";
19
+ /**
20
+ * Indicates that the player is currently loading more data before it can
21
+ * continue playing or is ready to start playing.
22
+ */
23
+ State["Buffering"] = "buffering";
24
+ /**
25
+ * Indicates that playback of the current item failed. Call `TrackPlayer.getError()`
26
+ * to get more information on the type of error that occurred.
27
+ * Call `TrackPlayer.retry()` or `TrackPlayer.play()` to try to play the item
28
+ * again.
29
+ */
30
+ State["Error"] = "error";
31
+ /**
32
+ * Indicates that playback stopped due to the end of the queue being reached.
33
+ */
34
+ State["Ended"] = "ended";
35
+ })(State || (State = {}));
@@ -0,0 +1,6 @@
1
+ export declare enum TrackType {
2
+ Default = "default",
3
+ Dash = "dash",
4
+ HLS = "hls",
5
+ SmoothStreaming = "smoothstreaming"
6
+ }
@@ -0,0 +1,7 @@
1
+ export var TrackType;
2
+ (function (TrackType) {
3
+ TrackType["Default"] = "default";
4
+ TrackType["Dash"] = "dash";
5
+ TrackType["HLS"] = "hls";
6
+ TrackType["SmoothStreaming"] = "smoothstreaming";
7
+ })(TrackType || (TrackType = {}));
@@ -0,0 +1,14 @@
1
+ export * from './AndroidAudioContentType';
2
+ export * from './AndroidAutoContentStyle';
3
+ export * from './AppKilledPlaybackBehavior';
4
+ export * from './Capability';
5
+ export * from './Event';
6
+ export * from './IOSCategory';
7
+ export * from './IOSCategoryMode';
8
+ export * from './IOSCategoryOptions';
9
+ export * from './PitchAlgorithm';
10
+ export * from './RatingType';
11
+ export * from './RepeatMode';
12
+ export * from './State';
13
+ export * from './TrackType';
14
+ export * from './MediaItemPlayable';
@@ -0,0 +1,14 @@
1
+ export * from './AndroidAudioContentType';
2
+ export * from './AndroidAutoContentStyle';
3
+ export * from './AppKilledPlaybackBehavior';
4
+ export * from './Capability';
5
+ export * from './Event';
6
+ export * from './IOSCategory';
7
+ export * from './IOSCategoryMode';
8
+ export * from './IOSCategoryOptions';
9
+ export * from './PitchAlgorithm';
10
+ export * from './RatingType';
11
+ export * from './RepeatMode';
12
+ export * from './State';
13
+ export * from './TrackType';
14
+ export * from './MediaItemPlayable';
@@ -0,0 +1,6 @@
1
+ export * from './useActiveTrack';
2
+ export * from './useIsPlaying';
3
+ export * from './usePlayWhenReady';
4
+ export * from './usePlaybackState';
5
+ export * from './useProgress';
6
+ export * from './useTrackPlayerEvents';
@@ -0,0 +1,6 @@
1
+ export * from './useActiveTrack';
2
+ export * from './useIsPlaying';
3
+ export * from './usePlayWhenReady';
4
+ export * from './usePlaybackState';
5
+ export * from './useProgress';
6
+ export * from './useTrackPlayerEvents';
@@ -0,0 +1,2 @@
1
+ import type { Track } from '../interfaces/Track';
2
+ export declare const useActiveTrack: () => Track | undefined;
@@ -0,0 +1,28 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { getActiveTrack } from '../trackPlayer';
3
+ import { Event } from '../constants';
4
+ import { useTrackPlayerEvents } from './useTrackPlayerEvents';
5
+ export const useActiveTrack = () => {
6
+ const [track, setTrack] = useState();
7
+ // Sets the initial index (if still undefined)
8
+ useEffect(() => {
9
+ let unmounted = false;
10
+ getActiveTrack()
11
+ .then((initialTrack) => {
12
+ if (unmounted)
13
+ return;
14
+ setTrack((track) => track ?? initialTrack ?? undefined);
15
+ })
16
+ .catch(() => {
17
+ // throws when you haven't yet setup, which is fine because it also
18
+ // means there's no active track
19
+ });
20
+ return () => {
21
+ unmounted = true;
22
+ };
23
+ }, []);
24
+ useTrackPlayerEvents([Event.PlaybackActiveTrackChanged], async ({ track }) => {
25
+ setTrack(track ?? undefined);
26
+ });
27
+ return track;
28
+ };
@@ -0,0 +1 @@
1
+ export declare function useAppIsInBackground(): boolean;
@@ -0,0 +1,16 @@
1
+ import { useState, useEffect, useRef } from 'react';
2
+ import { AppState } from 'react-native';
3
+ export function useAppIsInBackground() {
4
+ const [state, setState] = useState('active');
5
+ const eventListener = useRef(undefined);
6
+ useEffect(() => {
7
+ const onStateChange = (nextState) => {
8
+ setState(nextState);
9
+ };
10
+ eventListener.current = AppState.addEventListener('change', onStateChange);
11
+ return () => {
12
+ eventListener.current?.remove();
13
+ };
14
+ }, []);
15
+ return state === 'background';
16
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Tells whether the TrackPlayer is in a mode that most people would describe
3
+ * as "playing." Great for UI to decide whether to show a Play or Pause button.
4
+ * @returns playing - whether UI should likely show as Playing, or undefined
5
+ * if this isn't yet known.
6
+ * @returns bufferingDuringPlay - whether UI should show as Buffering, or
7
+ * undefined if this isn't yet known.
8
+ */
9
+ export declare function useIsPlaying(): {
10
+ playing: undefined;
11
+ bufferingDuringPlay: undefined;
12
+ } | {
13
+ playing: boolean;
14
+ bufferingDuringPlay: boolean;
15
+ };
16
+ /**
17
+ * This exists if you need realtime status on whether the TrackPlayer is
18
+ * playing, whereas the hooks all have a delay because they depend on responding
19
+ * to events before their state is updated.
20
+ *
21
+ * It also exists whenever you need to know the play state outside of a React
22
+ * component, since hooks only work in components.
23
+ *
24
+ * @returns playing - whether UI should likely show as Playing, or undefined
25
+ * if this isn't yet known.
26
+ * @returns bufferingDuringPlay - whether UI should show as Buffering, or
27
+ * undefined if this isn't yet known.
28
+ */
29
+ export declare function isPlaying(): Promise<{
30
+ playing: undefined;
31
+ bufferingDuringPlay: undefined;
32
+ } | {
33
+ playing: boolean;
34
+ bufferingDuringPlay: boolean;
35
+ }>;
@@ -0,0 +1,50 @@
1
+ import * as TrackPlayer from '../trackPlayer';
2
+ import { State } from '../constants';
3
+ import { usePlayWhenReady } from './usePlayWhenReady';
4
+ import { usePlaybackState } from './usePlaybackState';
5
+ /**
6
+ * Tells whether the TrackPlayer is in a mode that most people would describe
7
+ * as "playing." Great for UI to decide whether to show a Play or Pause button.
8
+ * @returns playing - whether UI should likely show as Playing, or undefined
9
+ * if this isn't yet known.
10
+ * @returns bufferingDuringPlay - whether UI should show as Buffering, or
11
+ * undefined if this isn't yet known.
12
+ */
13
+ export function useIsPlaying() {
14
+ const state = usePlaybackState().state;
15
+ const playWhenReady = usePlayWhenReady();
16
+ return determineIsPlaying(playWhenReady, state);
17
+ }
18
+ function determineIsPlaying(playWhenReady, state) {
19
+ if (playWhenReady === undefined || state === undefined) {
20
+ return { playing: undefined, bufferingDuringPlay: undefined };
21
+ }
22
+ const isLoading = state === State.Loading || state === State.Buffering;
23
+ const isErrored = state === State.Error;
24
+ const isEnded = state === State.Ended;
25
+ const isNone = state === State.None;
26
+ return {
27
+ playing: playWhenReady && !(isErrored || isEnded || isNone),
28
+ bufferingDuringPlay: playWhenReady && isLoading,
29
+ };
30
+ }
31
+ /**
32
+ * This exists if you need realtime status on whether the TrackPlayer is
33
+ * playing, whereas the hooks all have a delay because they depend on responding
34
+ * to events before their state is updated.
35
+ *
36
+ * It also exists whenever you need to know the play state outside of a React
37
+ * component, since hooks only work in components.
38
+ *
39
+ * @returns playing - whether UI should likely show as Playing, or undefined
40
+ * if this isn't yet known.
41
+ * @returns bufferingDuringPlay - whether UI should show as Buffering, or
42
+ * undefined if this isn't yet known.
43
+ */
44
+ export async function isPlaying() {
45
+ const [playbackState, playWhenReady] = await Promise.all([
46
+ TrackPlayer.getPlaybackState(),
47
+ TrackPlayer.getPlayWhenReady(),
48
+ ]);
49
+ return determineIsPlaying(playWhenReady, playbackState.state);
50
+ }
@@ -0,0 +1 @@
1
+ export declare const usePlayWhenReady: () => boolean | undefined;