react-native-nitro-player 0.0.1 → 0.3.0-alpha.5

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 (53) hide show
  1. package/README.md +1 -610
  2. package/android/src/main/java/com/margelo/nitro/nitroplayer/HybridAudioDevices.kt +37 -29
  3. package/android/src/main/java/com/margelo/nitro/nitroplayer/HybridTrackPlayer.kt +4 -0
  4. package/android/src/main/java/com/margelo/nitro/nitroplayer/core/TrackPlayerCore.kt +16 -0
  5. package/ios/HybridAudioRoutePicker.swift +47 -46
  6. package/ios/HybridTrackPlayer.swift +4 -0
  7. package/ios/core/TrackPlayerCore.swift +41 -0
  8. package/nitrogen/generated/android/c++/JHybridTrackPlayerSpec.cpp +9 -0
  9. package/nitrogen/generated/android/c++/JHybridTrackPlayerSpec.hpp +1 -0
  10. package/nitrogen/generated/android/c++/JRepeatMode.hpp +62 -0
  11. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroplayer/HybridTrackPlayerSpec.kt +4 -0
  12. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroplayer/RepeatMode.kt +22 -0
  13. package/nitrogen/generated/ios/NitroPlayer-Swift-Cxx-Umbrella.hpp +3 -0
  14. package/nitrogen/generated/ios/c++/HybridTrackPlayerSpecSwift.hpp +11 -0
  15. package/nitrogen/generated/ios/swift/HybridTrackPlayerSpec.swift +1 -0
  16. package/nitrogen/generated/ios/swift/HybridTrackPlayerSpec_cxx.swift +12 -0
  17. package/nitrogen/generated/ios/swift/RepeatMode.swift +44 -0
  18. package/nitrogen/generated/shared/c++/HybridTrackPlayerSpec.cpp +1 -0
  19. package/nitrogen/generated/shared/c++/HybridTrackPlayerSpec.hpp +4 -0
  20. package/nitrogen/generated/shared/c++/RepeatMode.hpp +80 -0
  21. package/package.json +7 -7
  22. package/src/index.ts +1 -1
  23. package/src/specs/TrackPlayer.nitro.ts +3 -0
  24. package/lib/hooks/index.d.ts +0 -6
  25. package/lib/hooks/index.js +0 -6
  26. package/lib/hooks/useAndroidAutoConnection.d.ts +0 -13
  27. package/lib/hooks/useAndroidAutoConnection.js +0 -26
  28. package/lib/hooks/useAudioDevices.d.ts +0 -26
  29. package/lib/hooks/useAudioDevices.js +0 -55
  30. package/lib/hooks/useOnChangeTrack.d.ts +0 -9
  31. package/lib/hooks/useOnChangeTrack.js +0 -17
  32. package/lib/hooks/useOnPlaybackProgressChange.d.ts +0 -9
  33. package/lib/hooks/useOnPlaybackProgressChange.js +0 -19
  34. package/lib/hooks/useOnPlaybackStateChange.d.ts +0 -9
  35. package/lib/hooks/useOnPlaybackStateChange.js +0 -17
  36. package/lib/hooks/useOnSeek.d.ts +0 -8
  37. package/lib/hooks/useOnSeek.js +0 -17
  38. package/lib/index.d.ts +0 -14
  39. package/lib/index.js +0 -24
  40. package/lib/specs/AndroidAutoMediaLibrary.nitro.d.ts +0 -21
  41. package/lib/specs/AndroidAutoMediaLibrary.nitro.js +0 -1
  42. package/lib/specs/AudioDevices.nitro.d.ts +0 -24
  43. package/lib/specs/AudioDevices.nitro.js +0 -1
  44. package/lib/specs/AudioRoutePicker.nitro.d.ts +0 -10
  45. package/lib/specs/AudioRoutePicker.nitro.js +0 -1
  46. package/lib/specs/TrackPlayer.nitro.d.ts +0 -39
  47. package/lib/specs/TrackPlayer.nitro.js +0 -1
  48. package/lib/types/AndroidAutoMediaLibrary.d.ts +0 -44
  49. package/lib/types/AndroidAutoMediaLibrary.js +0 -1
  50. package/lib/types/PlayerQueue.d.ts +0 -32
  51. package/lib/types/PlayerQueue.js +0 -1
  52. package/lib/utils/androidAutoMediaLibrary.d.ts +0 -47
  53. package/lib/utils/androidAutoMediaLibrary.js +0 -62
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// RepeatMode.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nitroplayer {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (RepeatMode).
30
+ */
31
+ enum class RepeatMode {
32
+ OFF SWIFT_NAME(off) = 0,
33
+ PLAYLIST SWIFT_NAME(playlist) = 1,
34
+ TRACK SWIFT_NAME(track) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::nitroplayer
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ RepeatMode <> JS RepeatMode (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::nitroplayer::RepeatMode> final {
44
+ static inline margelo::nitro::nitroplayer::RepeatMode fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("off"): return margelo::nitro::nitroplayer::RepeatMode::OFF;
48
+ case hashString("Playlist"): return margelo::nitro::nitroplayer::RepeatMode::PLAYLIST;
49
+ case hashString("track"): return margelo::nitro::nitroplayer::RepeatMode::TRACK;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum RepeatMode - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitroplayer::RepeatMode arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::nitroplayer::RepeatMode::OFF: return JSIConverter<std::string>::toJSI(runtime, "off");
57
+ case margelo::nitro::nitroplayer::RepeatMode::PLAYLIST: return JSIConverter<std::string>::toJSI(runtime, "Playlist");
58
+ case margelo::nitro::nitroplayer::RepeatMode::TRACK: return JSIConverter<std::string>::toJSI(runtime, "track");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert RepeatMode to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("off"):
71
+ case hashString("Playlist"):
72
+ case hashString("track"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-player",
3
- "version": "0.0.1",
3
+ "version": "0.3.0-alpha.5",
4
4
  "description": "react-native-nitro-player",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -30,12 +30,13 @@
30
30
  "scripts": {
31
31
  "postinstall": "tsc || exit 0;",
32
32
  "typecheck": "tsc --noEmit",
33
- "clean": "rm -rf android/build node_modules/**/android/build lib",
33
+ "clean": "rm -rf android/build node_modules/**/android/build lib nitrogen",
34
34
  "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
35
35
  "lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
36
36
  "typescript": "tsc",
37
37
  "specs": "tsc --noEmit false && nitrogen --logLevel=\"debug\"",
38
- "release": "release-it"
38
+ "release": "release-it",
39
+ "build": "bun run clean && bun run specs && bun run typescript"
39
40
  },
40
41
  "keywords": [
41
42
  "react-native",
@@ -122,14 +123,13 @@
122
123
  "github": {
123
124
  "release": true
124
125
  },
126
+ "hooks": {
127
+ "after:bump": "bun run build"
128
+ },
125
129
  "plugins": {
126
130
  "@release-it/bumper": {
127
131
  "in": "package.json",
128
132
  "out": [
129
- {
130
- "file": "package.json",
131
- "path": "version"
132
- },
133
133
  {
134
134
  "file": "../package.json",
135
135
  "path": "version"
package/src/index.ts CHANGED
@@ -42,6 +42,6 @@ export * from './hooks'
42
42
  export * from './types/PlayerQueue'
43
43
  export * from './types/AndroidAutoMediaLibrary'
44
44
  export type { TAudioDevice } from './specs/AudioDevices.nitro'
45
-
45
+ export type { RepeatMode } from './specs/TrackPlayer.nitro'
46
46
  // Export utilities
47
47
  export { AndroidAutoMediaLibraryHelper } from './utils/androidAutoMediaLibrary'
@@ -54,6 +54,8 @@ export interface PlayerQueue
54
54
  ): void
55
55
  }
56
56
 
57
+ export type RepeatMode = 'off' | 'Playlist' | 'track'
58
+
57
59
  export interface TrackPlayer
58
60
  extends HybridObject<{ android: 'kotlin'; ios: 'swift' }> {
59
61
  play(): void
@@ -63,6 +65,7 @@ export interface TrackPlayer
63
65
  skipToPrevious(): void
64
66
  seek(position: number): void
65
67
  getState(): PlayerState
68
+ setRepeatMode(mode: RepeatMode): boolean
66
69
  configure(config: PlayerConfig): void
67
70
  onChangeTrack(callback: (track: TrackItem, reason?: Reason) => void): void
68
71
  onPlaybackStateChange(
@@ -1,6 +0,0 @@
1
- export { useOnChangeTrack } from './useOnChangeTrack';
2
- export { useOnPlaybackStateChange } from './useOnPlaybackStateChange';
3
- export { useOnSeek } from './useOnSeek';
4
- export { useOnPlaybackProgressChange } from './useOnPlaybackProgressChange';
5
- export { useAndroidAutoConnection } from './useAndroidAutoConnection';
6
- export { useAudioDevices } from './useAudioDevices';
@@ -1,6 +0,0 @@
1
- export { useOnChangeTrack } from './useOnChangeTrack';
2
- export { useOnPlaybackStateChange } from './useOnPlaybackStateChange';
3
- export { useOnSeek } from './useOnSeek';
4
- export { useOnPlaybackProgressChange } from './useOnPlaybackProgressChange';
5
- export { useAndroidAutoConnection } from './useAndroidAutoConnection';
6
- export { useAudioDevices } from './useAudioDevices';
@@ -1,13 +0,0 @@
1
- /**
2
- * Hook to detect Android Auto connection status using the official Android for Cars API
3
- * Based on: https://developer.android.com/training/cars/apps#car-connection
4
- *
5
- * @returns Object with isConnected boolean
6
- *
7
- * @example
8
- * const { isConnected } = useAndroidAutoConnection();
9
- * console.log('Android Auto connected:', isConnected);
10
- */
11
- export declare function useAndroidAutoConnection(): {
12
- isConnected: boolean;
13
- };
@@ -1,26 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { TrackPlayer } from '../index';
3
- /**
4
- * Hook to detect Android Auto connection status using the official Android for Cars API
5
- * Based on: https://developer.android.com/training/cars/apps#car-connection
6
- *
7
- * @returns Object with isConnected boolean
8
- *
9
- * @example
10
- * const { isConnected } = useAndroidAutoConnection();
11
- * console.log('Android Auto connected:', isConnected);
12
- */
13
- export function useAndroidAutoConnection() {
14
- const [isConnected, setIsConnected] = useState(false);
15
- useEffect(() => {
16
- // Set initial state
17
- const initialState = TrackPlayer.isAndroidAutoConnected();
18
- setIsConnected(initialState);
19
- // Listen for connection changes
20
- TrackPlayer.onAndroidAutoConnectionChange((connected) => {
21
- setIsConnected(connected);
22
- console.log('🚗 Android Auto connection changed:', connected);
23
- });
24
- }, []);
25
- return { isConnected };
26
- }
@@ -1,26 +0,0 @@
1
- import type { TAudioDevice } from '../specs/AudioDevices.nitro';
2
- /**
3
- * Hook to get audio devices (Android only)
4
- *
5
- * Polls for device changes every 2 seconds
6
- *
7
- * @returns Object containing the current list of audio devices
8
- *
9
- * @example
10
- * ```tsx
11
- * function MyComponent() {
12
- * const { devices } = useAudioDevices()
13
- *
14
- * return (
15
- * <View>
16
- * {devices.map(device => (
17
- * <Text key={device.id}>{device.name}</Text>
18
- * ))}
19
- * </View>
20
- * )
21
- * }
22
- * ```
23
- */
24
- export declare function useAudioDevices(): {
25
- devices: TAudioDevice[];
26
- };
@@ -1,55 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { Platform } from 'react-native';
3
- import { NitroModules } from 'react-native-nitro-modules';
4
- /**
5
- * Hook to get audio devices (Android only)
6
- *
7
- * Polls for device changes every 2 seconds
8
- *
9
- * @returns Object containing the current list of audio devices
10
- *
11
- * @example
12
- * ```tsx
13
- * function MyComponent() {
14
- * const { devices } = useAudioDevices()
15
- *
16
- * return (
17
- * <View>
18
- * {devices.map(device => (
19
- * <Text key={device.id}>{device.name}</Text>
20
- * ))}
21
- * </View>
22
- * )
23
- * }
24
- * ```
25
- */
26
- export function useAudioDevices() {
27
- const [devices, setDevices] = useState([]);
28
- useEffect(() => {
29
- if (Platform.OS !== 'android') {
30
- return undefined;
31
- }
32
- try {
33
- const AudioDevices = NitroModules.createHybridObject('AudioDevices');
34
- // Get initial devices
35
- const updateDevices = () => {
36
- try {
37
- const currentDevices = AudioDevices.getAudioDevices();
38
- setDevices(currentDevices);
39
- }
40
- catch (error) {
41
- console.error('Error getting audio devices:', error);
42
- }
43
- };
44
- updateDevices();
45
- // Poll for changes every 2 seconds
46
- const interval = setInterval(updateDevices, 2000);
47
- return () => clearInterval(interval);
48
- }
49
- catch (error) {
50
- console.error('Error setting up audio devices polling:', error);
51
- return undefined;
52
- }
53
- }, []);
54
- return { devices };
55
- }
@@ -1,9 +0,0 @@
1
- import type { TrackItem, Reason } from '../types/PlayerQueue';
2
- /**
3
- * Hook to get the current track and track change reason
4
- * @returns Object with current track and reason, or undefined if no track is playing
5
- */
6
- export declare function useOnChangeTrack(): {
7
- track: TrackItem | undefined;
8
- reason: Reason | undefined;
9
- };
@@ -1,17 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { TrackPlayer } from '../index';
3
- /**
4
- * Hook to get the current track and track change reason
5
- * @returns Object with current track and reason, or undefined if no track is playing
6
- */
7
- export function useOnChangeTrack() {
8
- const [track, setTrack] = useState(undefined);
9
- const [reason, setReason] = useState(undefined);
10
- useEffect(() => {
11
- TrackPlayer.onChangeTrack((newTrack, newReason) => {
12
- setTrack(newTrack);
13
- setReason(newReason);
14
- });
15
- }, []);
16
- return { track, reason };
17
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Hook to get the current playback progress
3
- * @returns Object with current position, total duration, and manual seek indicator
4
- */
5
- export declare function useOnPlaybackProgressChange(): {
6
- position: number;
7
- totalDuration: number;
8
- isManuallySeeked: boolean | undefined;
9
- };
@@ -1,19 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { TrackPlayer } from '../index';
3
- /**
4
- * Hook to get the current playback progress
5
- * @returns Object with current position, total duration, and manual seek indicator
6
- */
7
- export function useOnPlaybackProgressChange() {
8
- const [position, setPosition] = useState(0);
9
- const [totalDuration, setTotalDuration] = useState(0);
10
- const [isManuallySeeked, setIsManuallySeeked] = useState(undefined);
11
- useEffect(() => {
12
- TrackPlayer.onPlaybackProgressChange((newPosition, newTotalDuration, newIsManuallySeeked) => {
13
- setPosition(newPosition);
14
- setTotalDuration(newTotalDuration);
15
- setIsManuallySeeked(newIsManuallySeeked);
16
- });
17
- }, []);
18
- return { position, totalDuration, isManuallySeeked };
19
- }
@@ -1,9 +0,0 @@
1
- import type { TrackPlayerState, Reason } from '../types/PlayerQueue';
2
- /**
3
- * Hook to get the current playback state and reason
4
- * @returns Object with current playback state and reason
5
- */
6
- export declare function useOnPlaybackStateChange(): {
7
- state: TrackPlayerState | undefined;
8
- reason: Reason | undefined;
9
- };
@@ -1,17 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { TrackPlayer } from '../index';
3
- /**
4
- * Hook to get the current playback state and reason
5
- * @returns Object with current playback state and reason
6
- */
7
- export function useOnPlaybackStateChange() {
8
- const [state, setState] = useState(undefined);
9
- const [reason, setReason] = useState(undefined);
10
- useEffect(() => {
11
- TrackPlayer.onPlaybackStateChange((newState, newReason) => {
12
- setState(newState);
13
- setReason(newReason);
14
- });
15
- }, []);
16
- return { state, reason };
17
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Hook to get the last seek event information
3
- * @returns Object with last seek position and total duration, or undefined if no seek has occurred
4
- */
5
- export declare function useOnSeek(): {
6
- position: number | undefined;
7
- totalDuration: number | undefined;
8
- };
@@ -1,17 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { TrackPlayer } from '../index';
3
- /**
4
- * Hook to get the last seek event information
5
- * @returns Object with last seek position and total duration, or undefined if no seek has occurred
6
- */
7
- export function useOnSeek() {
8
- const [position, setPosition] = useState(undefined);
9
- const [totalDuration, setTotalDuration] = useState(undefined);
10
- useEffect(() => {
11
- TrackPlayer.onSeek((newPosition, newTotalDuration) => {
12
- setPosition(newPosition);
13
- setTotalDuration(newTotalDuration);
14
- });
15
- }, []);
16
- return { position, totalDuration };
17
- }
package/lib/index.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { PlayerQueue as PlayerQueueType, TrackPlayer as TrackPlayerType } from './specs/TrackPlayer.nitro';
2
- import type { AndroidAutoMediaLibrary as AndroidAutoMediaLibraryType } from './specs/AndroidAutoMediaLibrary.nitro';
3
- import type { AudioDevices as AudioDevicesType } from './specs/AudioDevices.nitro';
4
- import type { AudioRoutePicker as AudioRoutePickerType } from './specs/AudioRoutePicker.nitro';
5
- export declare const PlayerQueue: PlayerQueueType;
6
- export declare const TrackPlayer: TrackPlayerType;
7
- export declare const AndroidAutoMediaLibrary: AndroidAutoMediaLibraryType | null;
8
- export declare const AudioDevices: AudioDevicesType | null;
9
- export declare const AudioRoutePicker: AudioRoutePickerType | null;
10
- export * from './hooks';
11
- export * from './types/PlayerQueue';
12
- export * from './types/AndroidAutoMediaLibrary';
13
- export type { TAudioDevice } from './specs/AudioDevices.nitro';
14
- export { AndroidAutoMediaLibraryHelper } from './utils/androidAutoMediaLibrary';
package/lib/index.js DELETED
@@ -1,24 +0,0 @@
1
- // TODO: Export all HybridObjects here for the user
2
- import { NitroModules } from 'react-native-nitro-modules';
3
- import { Platform } from 'react-native';
4
- export const PlayerQueue = NitroModules.createHybridObject('PlayerQueue');
5
- export const TrackPlayer = NitroModules.createHybridObject('TrackPlayer');
6
- // Android-only: Android Auto Media Library
7
- export const AndroidAutoMediaLibrary = Platform.OS === 'android'
8
- ? NitroModules.createHybridObject('AndroidAutoMediaLibrary')
9
- : null;
10
- // Android-only: Audio Devices
11
- export const AudioDevices = Platform.OS === 'android'
12
- ? NitroModules.createHybridObject('AudioDevices')
13
- : null;
14
- // iOS-only: Audio Route Picker
15
- export const AudioRoutePicker = Platform.OS === 'ios'
16
- ? NitroModules.createHybridObject('AudioRoutePicker')
17
- : null;
18
- // Export hooks
19
- export * from './hooks';
20
- // Export types
21
- export * from './types/PlayerQueue';
22
- export * from './types/AndroidAutoMediaLibrary';
23
- // Export utilities
24
- export { AndroidAutoMediaLibraryHelper } from './utils/androidAutoMediaLibrary';
@@ -1,21 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- /**
3
- * Android Auto Media Library Manager
4
- * Android-only HybridObject for managing Android Auto media browser structure
5
- */
6
- export interface AndroidAutoMediaLibrary extends HybridObject<{
7
- android: 'kotlin';
8
- }> {
9
- /**
10
- * Set the Android Auto media library structure
11
- * This defines what folders and playlists appear in Android Auto
12
- *
13
- * @param libraryJson - JSON string of the MediaLibrary structure
14
- */
15
- setMediaLibrary(libraryJson: string): void;
16
- /**
17
- * Clear the Android Auto media library
18
- * Falls back to showing all playlists
19
- */
20
- clearMediaLibrary(): void;
21
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- export type TAudioDevice = {
3
- id: number;
4
- name: string;
5
- type: number;
6
- isActive: boolean;
7
- };
8
- export interface AudioDevices extends HybridObject<{
9
- android: 'kotlin';
10
- }> {
11
- /**
12
- * Get the list of audio devices
13
- *
14
- * @returns The list of audio devices
15
- */
16
- getAudioDevices(): TAudioDevice[];
17
- /**
18
- * Set the audio device
19
- *
20
- * @param deviceId - The ID of the audio device
21
- * @returns True if the audio device was set successfully, false otherwise
22
- */
23
- setAudioDevice(deviceId: number): boolean;
24
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- export interface AudioRoutePicker extends HybridObject<{
3
- ios: 'swift';
4
- }> {
5
- /**
6
- * Show the audio route picker view (iOS only)
7
- * This presents a native AVRoutePickerView for selecting audio output devices like AirPlay
8
- */
9
- showRoutePicker(): void;
10
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,39 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { QueueOperation, Reason, TrackItem, TrackPlayerState, PlayerState, PlayerConfig, Playlist } from '../types/PlayerQueue';
3
- export interface PlayerQueue extends HybridObject<{
4
- android: 'kotlin';
5
- ios: 'swift';
6
- }> {
7
- createPlaylist(name: string, description?: string, artwork?: string): string;
8
- deletePlaylist(playlistId: string): void;
9
- updatePlaylist(playlistId: string, name?: string, description?: string, artwork?: string): void;
10
- getPlaylist(playlistId: string): Playlist | null;
11
- getAllPlaylists(): Playlist[];
12
- addTrackToPlaylist(playlistId: string, track: TrackItem, index?: number): void;
13
- addTracksToPlaylist(playlistId: string, tracks: TrackItem[], index?: number): void;
14
- removeTrackFromPlaylist(playlistId: string, trackId: string): void;
15
- reorderTrackInPlaylist(playlistId: string, trackId: string, newIndex: number): void;
16
- loadPlaylist(playlistId: string): void;
17
- getCurrentPlaylistId(): string | null;
18
- onPlaylistsChanged(callback: (playlists: Playlist[], operation?: QueueOperation) => void): void;
19
- onPlaylistChanged(callback: (playlistId: string, playlist: Playlist, operation?: QueueOperation) => void): void;
20
- }
21
- export interface TrackPlayer extends HybridObject<{
22
- android: 'kotlin';
23
- ios: 'swift';
24
- }> {
25
- play(): void;
26
- pause(): void;
27
- playSong(songId: string, fromPlaylist?: string): void;
28
- skipToNext(): void;
29
- skipToPrevious(): void;
30
- seek(position: number): void;
31
- getState(): PlayerState;
32
- configure(config: PlayerConfig): void;
33
- onChangeTrack(callback: (track: TrackItem, reason?: Reason) => void): void;
34
- onPlaybackStateChange(callback: (state: TrackPlayerState, reason?: Reason) => void): void;
35
- onSeek(callback: (position: number, totalDuration: number) => void): void;
36
- onPlaybackProgressChange(callback: (position: number, totalDuration: number, isManuallySeeked?: boolean) => void): void;
37
- onAndroidAutoConnectionChange(callback: (connected: boolean) => void): void;
38
- isAndroidAutoConnected(): boolean;
39
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,44 +0,0 @@
1
- /**
2
- * Layout type for the Android Auto media browser
3
- */
4
- export type LayoutType = 'grid' | 'list';
5
- /**
6
- * Media type for different kinds of content
7
- */
8
- export type MediaType = 'folder' | 'audio' | 'playlist';
9
- /**
10
- * Media item that can be displayed in Android Auto
11
- */
12
- export interface MediaItem {
13
- /** Unique identifier for the media item */
14
- id: string;
15
- /** Display title */
16
- title: string;
17
- /** Optional subtitle/description */
18
- subtitle?: string;
19
- /** Optional icon/artwork URL */
20
- iconUrl?: string;
21
- /** Whether this item can be played directly */
22
- isPlayable: boolean;
23
- /** Media type */
24
- mediaType: MediaType;
25
- /** Reference to playlist ID (for playlist items) - will load tracks from this playlist */
26
- playlistId?: string;
27
- /** Child items for browsable folders */
28
- children?: MediaItem[];
29
- /** Layout type for folder items (overrides library default) */
30
- layoutType?: LayoutType;
31
- }
32
- /**
33
- * Media library structure for Android Auto
34
- */
35
- export interface MediaLibrary {
36
- /** Layout type for the media browser (applies to all folders by default) */
37
- layoutType: LayoutType;
38
- /** Root level media items */
39
- rootItems: MediaItem[];
40
- /** Optional app name to display */
41
- appName?: string;
42
- /** Optional app icon URL */
43
- appIconUrl?: string;
44
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,32 +0,0 @@
1
- export interface TrackItem {
2
- id: string;
3
- title: string;
4
- artist: string;
5
- album: string;
6
- duration: number;
7
- url: string;
8
- artwork?: string | null;
9
- }
10
- export interface Playlist {
11
- id: string;
12
- name: string;
13
- description?: string | null;
14
- artwork?: string | null;
15
- tracks: TrackItem[];
16
- }
17
- export type QueueOperation = 'add' | 'remove' | 'clear' | 'update';
18
- export type TrackPlayerState = 'playing' | 'paused' | 'stopped';
19
- export type Reason = 'user_action' | 'skip' | 'end' | 'error';
20
- export interface PlayerState {
21
- currentTrack: TrackItem | null;
22
- currentPosition: number;
23
- totalDuration: number;
24
- currentState: TrackPlayerState;
25
- currentPlaylistId: string | null;
26
- currentIndex: number;
27
- }
28
- export interface PlayerConfig {
29
- androidAutoEnabled?: boolean;
30
- carPlayEnabled?: boolean;
31
- showInNotification?: boolean;
32
- }
@@ -1 +0,0 @@
1
- export {};