mirror of
https://github.com/Boof2015/astra-mobile.git
synced 2026-08-19 04:06:43 +02:00
m1, add file scan, library, browse, play, seek
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { requireNativeModule, type NativeModule } from 'expo-modules-core';
|
||||
|
||||
/** A single audio file found during the SAF tree walk. */
|
||||
export interface ScannedFile {
|
||||
/** SAF document URI — playable directly by ExoPlayer and readable by MMR. */
|
||||
uri: string;
|
||||
name: string;
|
||||
size: number | null;
|
||||
lastModified: number;
|
||||
mimeType: string | null;
|
||||
/** Document URI of the containing directory (key into `ListResult.covers`). */
|
||||
parentUri: string;
|
||||
}
|
||||
|
||||
export interface ListResult {
|
||||
files: ScannedFile[];
|
||||
/** Best external cover-art candidate per directory (cover/folder/front/albumart). */
|
||||
covers: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface ExtractedMetadata {
|
||||
uri: string;
|
||||
ok: boolean;
|
||||
error?: string;
|
||||
title?: string | null;
|
||||
artist?: string | null;
|
||||
album?: string | null;
|
||||
albumArtist?: string | null;
|
||||
genre?: string | null;
|
||||
/** Container mime type reported by MediaMetadataRetriever. */
|
||||
mimeType?: string | null;
|
||||
/** Audio track mime type from MediaExtractor (e.g. "audio/flac"). */
|
||||
codecMime?: string | null;
|
||||
durationMs?: number | null;
|
||||
bitrate?: number | null;
|
||||
trackNumber?: number | null;
|
||||
discNumber?: number | null;
|
||||
year?: number | null;
|
||||
sampleRate?: number | null;
|
||||
channels?: number | null;
|
||||
bitsPerSample?: number | null;
|
||||
/** File name in the artwork cache dir: `md5(bytes) + extension`. */
|
||||
artworkHash?: string | null;
|
||||
}
|
||||
|
||||
export interface ScanProgressEvent {
|
||||
phase: 'discovering';
|
||||
found: number;
|
||||
}
|
||||
|
||||
type AstraLibraryScannerEvents = {
|
||||
onScanProgress: (event: ScanProgressEvent) => void;
|
||||
};
|
||||
|
||||
declare class AstraLibraryScannerModuleType extends NativeModule<AstraLibraryScannerEvents> {
|
||||
listAudioFiles(treeUri: string, extensions: string[]): Promise<ListResult>;
|
||||
extractMetadata(files: { uri: string; coverUri?: string | null }[]): Promise<ExtractedMetadata[]>;
|
||||
getArtworkDirPath(): string;
|
||||
getPersistedTreeUris(): string[];
|
||||
takePersistableUriPermission(uri: string): Promise<boolean>;
|
||||
releasePersistedUriPermission(uri: string): Promise<void>;
|
||||
}
|
||||
|
||||
export const AstraLibraryScanner =
|
||||
requireNativeModule<AstraLibraryScannerModuleType>('AstraLibraryScanner');
|
||||
Reference in New Issue
Block a user