feat: play downloads

This commit is contained in:
Adrian Castro
2024-03-21 14:14:30 +01:00
parent 13143a2664
commit 21b574ee87
8 changed files with 79 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
import type { AVPlaybackStatus, Video } from "expo-av";
import type { Asset } from "expo-media-library";
import type { ScrapeMedia } from "@movie-web/provider-utils";
@@ -31,10 +32,12 @@ export interface VideoSlice {
videoRef: Video | null;
status: AVPlaybackStatus | null;
meta: PlayerMeta | null;
asset: Asset | null;
setVideoRef(ref: Video | null): void;
setStatus(status: AVPlaybackStatus | null): void;
setMeta(meta: PlayerMeta | null): void;
setAsset(asset: Asset | null): void;
resetVideo(): void;
}
@@ -66,6 +69,7 @@ export const createVideoSlice: MakeSlice<VideoSlice> = (set) => ({
videoRef: null,
status: null,
meta: null,
asset: null,
setVideoRef: (ref) => {
set({ videoRef: ref });
@@ -81,8 +85,13 @@ export const createVideoSlice: MakeSlice<VideoSlice> = (set) => ({
s.meta = meta;
});
},
setAsset: (asset) => {
set((s) => {
s.asset = asset;
});
},
resetVideo() {
set({ videoRef: null, status: null, meta: null });
set({ videoRef: null, status: null, meta: null, asset: null });
set((s) => {
s.interface.playerStatus = PlayerStatus.SCRAPING;
});