mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
Cleanup setSource
This commit is contained in:
+4
-10
@@ -6,7 +6,6 @@ import type {
|
||||
Rendition,
|
||||
Track,
|
||||
} from "./types/player";
|
||||
import type { Source } from "./types/source";
|
||||
|
||||
export class WebOmniPlayer implements OmniPlayer {
|
||||
_store: VideoPlayerStore;
|
||||
@@ -17,19 +16,12 @@ export class WebOmniPlayer implements OmniPlayer {
|
||||
this._store = store;
|
||||
}
|
||||
|
||||
get source(): Source {
|
||||
// TODO
|
||||
}
|
||||
|
||||
set source(source: Source) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
get showNotification(): boolean {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
set showNotification(value: boolean) {
|
||||
set showNotification(_: boolean) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@@ -108,10 +100,12 @@ export class WebOmniPlayer implements OmniPlayer {
|
||||
|
||||
get hasPrev(): boolean {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
get hasNext(): boolean {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
get videos(): Track[] {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ export const OmniProvider = ({
|
||||
const player = useLazyRef(() => ProviderFactory.createPlayer(source));
|
||||
|
||||
useEffect(() => {
|
||||
player.source = source;
|
||||
player.setSource(source);
|
||||
}, [source]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
+5
-12
@@ -1,15 +1,8 @@
|
||||
import { createPlayer } from "@videojs/react";
|
||||
import { videoFeatures } from "@videojs/react/video";
|
||||
import {
|
||||
createContext,
|
||||
type ReactNode,
|
||||
useContext,
|
||||
useEffect,
|
||||
} from "react";
|
||||
import { createContext, type ReactNode, useContext, useEffect } from "react";
|
||||
import { WebOmniPlayer } from "./player.web";
|
||||
import type {
|
||||
OmniPlayer,
|
||||
} from "./types/player";
|
||||
import type { OmniPlayer } from "./types/player";
|
||||
import type { Source } from "./types/source";
|
||||
import { useLazyRef } from "./utils/lazy-ref";
|
||||
|
||||
@@ -45,11 +38,11 @@ const PlayerInitializer = ({
|
||||
showNotification: boolean;
|
||||
}) => {
|
||||
const store = VideoPlayer.usePlayer();
|
||||
const player = useLazyRef(() => new WebOmniPlayer(store, source));
|
||||
const player = useLazyRef(() => new WebOmniPlayer(store));
|
||||
|
||||
useEffect(() => {
|
||||
player.updateSource(source);
|
||||
}, [source]);
|
||||
store.source = source.src[0]?.uri || null;
|
||||
}, [store, source]);
|
||||
|
||||
useEffect(() => {
|
||||
player.showNotification = showNotification;
|
||||
|
||||
@@ -56,6 +56,8 @@ export interface OmniPlayer
|
||||
extends HybridObject<{ android: "kotlin" }>,
|
||||
OmniPlayerT {
|
||||
readonly eventMap: OmniEventMap;
|
||||
|
||||
setSource(src: Source): void;
|
||||
}
|
||||
|
||||
export interface OmniPlayerFactory extends HybridObject<{ android: "kotlin" }> {
|
||||
|
||||
+1
-4
@@ -1,7 +1,4 @@
|
||||
import type { Source } from "./source";
|
||||
|
||||
export interface OmniPlayer extends OmniPlayerState {
|
||||
source: Source;
|
||||
showNotification?: boolean;
|
||||
|
||||
play(): void;
|
||||
@@ -34,7 +31,7 @@ export interface OmniPlayerState {
|
||||
// between 0 and 1
|
||||
volume: number;
|
||||
muted: boolean;
|
||||
readonly isAutoQuality: boolean
|
||||
readonly isAutoQuality: boolean;
|
||||
}
|
||||
|
||||
export type PlayerStatus = "idle" | "loading" | "readyToPlay" | "error";
|
||||
|
||||
Reference in New Issue
Block a user