diff --git a/example/src/App.tsx b/example/src/App.tsx
index 3be6941c..dd7364a0 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -1,5 +1,5 @@
import * as React from 'react';
-import { Button, Dimensions, Platform, StyleSheet, View } from 'react-native';
+import { Button, Dimensions, StyleSheet, View } from 'react-native';
import { VideoView, createSource, useVideoPlayer } from 'react-native-video';
export default function App() {
@@ -10,32 +10,39 @@ export default function App() {
return (
- {/* */}
- {/* Two VideoViews with same player are supported not supported on Android */}
- {show && (
-
- )}
+ {show && }
);
}
diff --git a/src/index.tsx b/src/index.tsx
index 3217a4f9..081d47db 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -3,4 +3,4 @@ export { useVideoPlayer } from './utils/useVideoPlayer';
export { createPlayer, createSource } from './utils/factory';
export type { VideoPlayer } from './spec/nitro/VideoPlayer.nitro';
-export type { VideoSource } from './types/VideoConfig';
\ No newline at end of file
+export type { VideoSource } from './types/VideoConfig';
diff --git a/src/types/VideoConfig.ts b/src/types/VideoConfig.ts
index 886dd448..2a28fd60 100644
--- a/src/types/VideoConfig.ts
+++ b/src/types/VideoConfig.ts
@@ -1,5 +1,5 @@
export type VideoSource = number | string;
export type VideoConfig = {
- uri: VideoSource;
-}
\ No newline at end of file
+ uri: VideoSource;
+};
diff --git a/src/types/VideoInformation.ts b/src/types/VideoInformation.ts
index 4859b122..4586daf1 100644
--- a/src/types/VideoInformation.ts
+++ b/src/types/VideoInformation.ts
@@ -1,4 +1,10 @@
-export type VideoOrientation = "portrait" | "landscape" | "portrait-upside-down" | "landscape-left" | "landscape-right" | "unknown";
+export type VideoOrientation =
+ | 'portrait'
+ | 'landscape'
+ | 'portrait-upside-down'
+ | 'landscape-left'
+ | 'landscape-right'
+ | 'unknown';
export interface VideoInformation {
/**
@@ -41,4 +47,4 @@ export interface VideoInformation {
* see {@link VideoOrientation}
*/
orientation: VideoOrientation;
-}
\ No newline at end of file
+}
diff --git a/src/utils/factory.ts b/src/utils/factory.ts
index 99039ddc..4560d8ee 100644
--- a/src/utils/factory.ts
+++ b/src/utils/factory.ts
@@ -1,8 +1,11 @@
-import { NitroModules } from "react-native-nitro-modules";
-import type { VideoPlayer, VideoPlayerFactory } from '../spec/nitro/VideoPlayer.nitro';
+import { NitroModules } from 'react-native-nitro-modules';
+import type {
+ VideoPlayer,
+ VideoPlayerFactory,
+} from '../spec/nitro/VideoPlayer.nitro';
import type { VideoPlayerSourceFactory } from '../spec/nitro/VideoPlayerSource.nitro';
-import type { VideoConfig, VideoSource } from "../types/VideoConfig";
-import { Image } from "react-native";
+import type { VideoConfig, VideoSource } from '../types/VideoConfig';
+import { Image } from 'react-native';
// ----------- Factories -----------
const VideoPlayerSourceFactory =
@@ -14,20 +17,26 @@ const VideoPlayerFactory =
NitroModules.createHybridObject('VideoPlayerFactory');
// ----------- Factories functions -----------
-export const createPlayer = (source: VideoSource | VideoConfig): VideoPlayer => {
+export const createPlayer = (
+ source: VideoSource | VideoConfig
+): VideoPlayer => {
// If source is a string, we can directly create the player
if (typeof source === 'string') {
- return VideoPlayerFactory.createPlayer(VideoPlayerSourceFactory.fromUri(source));
+ return VideoPlayerFactory.createPlayer(
+ VideoPlayerSourceFactory.fromUri(source)
+ );
}
// If source is a number (asset), we need to resolve the asset source and create the player
if (typeof source === 'number') {
- return VideoPlayerFactory.createPlayer(VideoPlayerSourceFactory.fromUri(Image.resolveAssetSource(source).uri));
+ return VideoPlayerFactory.createPlayer(
+ VideoPlayerSourceFactory.fromUri(Image.resolveAssetSource(source).uri)
+ );
}
// If source is an object (VideoConfig)
if (typeof source === 'object' && 'uri' in source) {
- return createPlayer(source.uri)
+ return createPlayer(source.uri);
}
throw new Error('RNV: Invalid source type');
@@ -35,4 +44,4 @@ export const createPlayer = (source: VideoSource | VideoConfig): VideoPlayer =>
export const createSource = (uri: string) => {
return VideoPlayerSourceFactory.fromUri(uri);
-};
\ No newline at end of file
+};
diff --git a/src/utils/useVideoPlayer.ts b/src/utils/useVideoPlayer.ts
index bd56c49c..c4e2b6c9 100644
--- a/src/utils/useVideoPlayer.ts
+++ b/src/utils/useVideoPlayer.ts
@@ -1,25 +1,22 @@
-import type { VideoPlayer } from "../spec/nitro/VideoPlayer.nitro";
-import { useReleasingHybridObject } from "./useReleasingHybridObject";
-import { createPlayer } from "./factory";
-import type { VideoConfig, VideoSource } from "../types/VideoConfig";
+import type { VideoPlayer } from '../spec/nitro/VideoPlayer.nitro';
+import { useReleasingHybridObject } from './useReleasingHybridObject';
+import { createPlayer } from './factory';
+import type { VideoConfig, VideoSource } from '../types/VideoConfig';
/**
* A hook that creates and manages a video player.
- *
+ *
* @param source - The source of the video.
* @param setup - A function that allow to setup the video player after it is created.
* @returns VideoPlayer (see {@link VideoPlayer})
*/
export const useVideoPlayer = (
- source: VideoConfig | VideoSource,
- setup?: (player: VideoPlayer) => void
+ source: VideoConfig | VideoSource,
+ setup?: (player: VideoPlayer) => void
) => {
- return useReleasingHybridObject(
- () => {
- const videoPlayer = createPlayer(source);
- setup?.(videoPlayer);
- return videoPlayer;
- },
- [source]
- );
-}
\ No newline at end of file
+ return useReleasingHybridObject(() => {
+ const videoPlayer = createPlayer(source);
+ setup?.(videoPlayer);
+ return videoPlayer;
+ }, [source]);
+};