@andycui/react-native-get-music-files 3.0.1
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 +20 -0
- package/README.md +226 -0
- package/android/build.gradle +127 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/turbosongs/BundlePair.kt +95 -0
- package/android/src/main/java/com/turbosongs/TurboSongsModule.kt +498 -0
- package/android/src/main/java/com/turbosongs/TurboSongsPackage.kt +35 -0
- package/android/src/newarch/TurboSongsSpec.kt +7 -0
- package/android/src/oldarch/TurboSongsSpec.kt +14 -0
- package/ios/TurboSongs.h +12 -0
- package/ios/TurboSongs.mm +420 -0
- package/package.json +171 -0
- package/react-native-turbo-songs.podspec +41 -0
- package/src/NativeTurboSongs.ts +60 -0
- package/src/index.tsx +70 -0
package/src/index.tsx
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
import type {
|
|
3
|
+
Album,
|
|
4
|
+
AlbumOptions,
|
|
5
|
+
Song,
|
|
6
|
+
SongOptions,
|
|
7
|
+
} from './NativeTurboSongs';
|
|
8
|
+
|
|
9
|
+
const LINKING_ERROR =
|
|
10
|
+
`The package 'react-native-music-files' doesn't seem to be linked. Make sure: \n\n` +
|
|
11
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
12
|
+
'- You rebuilt the app after installing the package\n' +
|
|
13
|
+
'- You are not using Expo Go\n';
|
|
14
|
+
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
17
|
+
|
|
18
|
+
const TurboSongsModule = isTurboModuleEnabled
|
|
19
|
+
? require('./NativeTurboSongs').default
|
|
20
|
+
: NativeModules.TurboSongs;
|
|
21
|
+
|
|
22
|
+
const TurboSongs = TurboSongsModule
|
|
23
|
+
? TurboSongsModule
|
|
24
|
+
: new Proxy(
|
|
25
|
+
{},
|
|
26
|
+
{
|
|
27
|
+
get() {
|
|
28
|
+
throw new Error(LINKING_ERROR);
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
enum SortSongOrder {
|
|
34
|
+
ASC = 'ASC',
|
|
35
|
+
DESC = 'DESC',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
enum SortSongFields {
|
|
39
|
+
TITLE = 'TITLE',
|
|
40
|
+
DURATION = 'DURATION',
|
|
41
|
+
ARTIST = 'ARTIST',
|
|
42
|
+
GENRE = 'GENRE',
|
|
43
|
+
ALBUM = 'ALBUM',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const getAll = async (options?: SongOptions): Promise<Song[] | string> => {
|
|
47
|
+
try {
|
|
48
|
+
return await TurboSongs.getAll(options);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return `${e}`;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const getAlbums = async (options?: AlbumOptions): Promise<Album[] | string> => {
|
|
55
|
+
try {
|
|
56
|
+
return await TurboSongs.getAlbums(options);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
return `${e}`;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const searchSongs = async (options?: SongOptions): Promise<Song[] | string> => {
|
|
63
|
+
try {
|
|
64
|
+
return await TurboSongs.search(options);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
return `${e}`;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { getAll, getAlbums, searchSongs, SortSongFields, SortSongOrder };
|