Skip to content

Commit

Permalink
feat: local playback
Browse files Browse the repository at this point in the history
  • Loading branch information
lovegaoshi committed Feb 23, 2024
1 parent 65b59fa commit de4c7e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/components/player/TrackInfo/AlbumArt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const AlbumArt: React.FC<Props> = ({
useNativeDriver: true,
}),
]).start(() => {
console.log('artwork', track?.artwork);
console.log('TrackInfo: Setting imagevisible to Image', !isImageVisible);
setIsImageVisible(false);
});
Expand Down
10 changes: 3 additions & 7 deletions src/stores/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { logger } from '@utils/Logger';
import rejson from '../utils/rejson.json';
import { LoadJSONRegExtractors } from '../utils/re';
import { SOURCE } from '@enums/MediaFetch';

interface AppStore {
pipMode: boolean;
Expand Down Expand Up @@ -181,12 +180,9 @@ export const cacheResolvedURL = async (
) {
logger.debug(`[CacheResolveURL] ${song.parsedName} needs to be refetched.`);
const result = await resolveURL(song);
// HACK: do not cache any local source files
if (song.source !== SOURCE.local) {
appStore.setState({
cachedResolveURLMap: { ...cachedResolveURLMap, [song.id]: result },
});
}
appStore.setState({
cachedResolveURLMap: { ...cachedResolveURLMap, [song.id]: result },
});
return result;
}
return cachedResolvedURL;
Expand Down
5 changes: 4 additions & 1 deletion src/utils/mediafetch/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* each site needs a fetch to parse regex extracted, a videoinfo fetcher and a song fetcher.
*/
import { Platform, NativeModules } from 'react-native';
import RNFetchBlob from 'react-native-blob-util';

import { probeMetadata, cacheAlbumArt } from '@utils/ffmpeg/ffmpeg';
import { SOURCE } from '@enums/MediaFetch';
Expand Down Expand Up @@ -55,7 +56,9 @@ const regexFetch = async ({
});

const resolveURL = async (song: NoxMedia.Song) => {
return { url: song.bvid, cover: await cacheAlbumArt(song.bvid) };
const artworkURI = await cacheAlbumArt(song.bvid);
const artworkBase64 = await RNFetchBlob.fs.readFile(artworkURI, 'base64');
return { url: song.bvid, cover: `data:image/png;base64,${artworkBase64}` };
};

const refreshSong = (song: NoxMedia.Song) => song;
Expand Down

0 comments on commit de4c7e4

Please sign in to comment.