mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 15:03:26 +00:00
feat: provider event logic & temp loading screen
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
export const name = "provider-utils";
|
||||
export * from "./video";
|
||||
export * from "./util";
|
||||
|
||||
import type { Stream, ScrapeMedia } from "@movie-web/providers";
|
||||
export type { Stream, ScrapeMedia };
|
||||
|
@@ -3,6 +3,7 @@ import { default as toWebVTT } from "srt-webvtt";
|
||||
import type {
|
||||
FileBasedStream,
|
||||
Qualities,
|
||||
RunnerOptions,
|
||||
ScrapeMedia,
|
||||
Stream,
|
||||
} from "@movie-web/providers";
|
||||
@@ -15,9 +16,11 @@ import {
|
||||
export async function getVideoStream({
|
||||
media,
|
||||
forceVTT,
|
||||
onEvent,
|
||||
}: {
|
||||
media: ScrapeMedia;
|
||||
forceVTT?: boolean;
|
||||
onEvent?: (event: unknown) => void;
|
||||
}): Promise<Stream | null> {
|
||||
const providers = makeProviders({
|
||||
fetcher: makeStandardFetcher(fetch),
|
||||
@@ -25,7 +28,17 @@ export async function getVideoStream({
|
||||
consistentIpForRequests: true,
|
||||
});
|
||||
|
||||
const result = await providers.runAll({ media });
|
||||
const options: RunnerOptions = {
|
||||
media,
|
||||
events: {
|
||||
init: onEvent,
|
||||
update: onEvent,
|
||||
discoverEmbeds: onEvent,
|
||||
start: onEvent,
|
||||
}
|
||||
};
|
||||
|
||||
const result = await providers.runAll(options);
|
||||
if (!result) return null;
|
||||
|
||||
if (forceVTT) {
|
||||
|
Reference in New Issue
Block a user