Skip to content

Commit

Permalink
chore: cleanup ref (#4288)
Browse files Browse the repository at this point in the history
* refactor: cleanup ref
* fix: video-ref type
* refactor: cleanup code
  • Loading branch information
moskalakamil authored Nov 15, 2024
1 parent 681aed0 commit de81829
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 30 deletions.
10 changes: 4 additions & 6 deletions examples/bare/src/BasicExample.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, {type FC, useCallback, useRef, useState, useEffect} from 'react';
import React, {useCallback, useRef, useState, useEffect} from 'react';

import {Platform, TouchableOpacity, View, StatusBar} from 'react-native';

import Video, {
VideoRef,
SelectedVideoTrackType,
BufferingStrategyType,
SelectedTrackType,
ResizeMode,
type VideoRef,
type AudioTrack,
type OnAudioTracksData,
type OnLoadData,
Expand All @@ -23,19 +23,17 @@ import Video, {
type OnPlaybackStateChangedData,
type OnPlaybackRateChangeData,
type OnVideoTracksData,
type ReactVideoSource,
type VideoTrack,
type SelectedTrack,
type SelectedVideoTrack,
type EnumValues,
OnBandwidthUpdateData,
ControlsStyles,
type OnBandwidthUpdateData,
type ControlsStyles,
} from 'react-native-video';
import styles from './styles';
import {type AdditionalSourceInfo} from './types';
import {
bufferConfig,
isAndroid,
srcList,
textTracksSelectionBy,
audioTracksSelectionBy,
Expand Down
10 changes: 4 additions & 6 deletions examples/expo/src/BasicExample.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, {type FC, useCallback, useRef, useState, useEffect} from 'react';
import React, {useCallback, useRef, useState, useEffect} from 'react';

import {Platform, TouchableOpacity, View, StatusBar} from 'react-native';

import Video, {
VideoRef,
SelectedVideoTrackType,
BufferingStrategyType,
SelectedTrackType,
ResizeMode,
type VideoRef,
type AudioTrack,
type OnAudioTracksData,
type OnLoadData,
Expand All @@ -23,19 +23,17 @@ import Video, {
type OnPlaybackStateChangedData,
type OnPlaybackRateChangeData,
type OnVideoTracksData,
type ReactVideoSource,
type VideoTrack,
type SelectedTrack,
type SelectedVideoTrack,
type EnumValues,
OnBandwidthUpdateData,
ControlsStyles,
type OnBandwidthUpdateData,
type ControlsStyles,
} from 'react-native-video';
import styles from './styles';
import {type AdditionalSourceInfo} from './types';
import {
bufferConfig,
isAndroid,
srcList,
textTracksSelectionBy,
audioTracksSelectionBy,
Expand Down
18 changes: 1 addition & 17 deletions src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
resolveAssetSourceForVideo,
} from './utils';
import NativeVideoManager from './specs/NativeVideoManager';
import {ViewType, type VideoSaveData, CmcdMode} from './types';
import {ViewType, CmcdMode, VideoRef} from './types';
import type {
OnLoadData,
OnTextTracksData,
Expand All @@ -55,22 +55,6 @@ import type {
ReactVideoSource,
} from './types';

export interface VideoRef {
seek: (time: number, tolerance?: number) => void;
resume: () => void;
pause: () => void;
presentFullscreenPlayer: () => void;
dismissFullscreenPlayer: () => void;
restoreUserInterfaceForPictureInPictureStopCompleted: (
restore: boolean,
) => void;
setVolume: (volume: number) => void;
setFullScreen: (fullScreen: boolean) => void;
setSource: (source?: ReactVideoSource) => void;
save: (options: object) => Promise<VideoSaveData> | void;
getCurrentPosition: () => Promise<number>;
}

const Video = forwardRef<VideoRef, ReactVideoProps>(
(
{
Expand Down
1 change: 1 addition & 0 deletions src/Video.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
fullscreenOrientation,
fullscreenAutorotate,
};

const setFullScreen = useCallback(
async (
newVal: boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/types/video-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface VideoRef {
restoreUserInterfaceForPictureInPictureStopCompleted: (
restore: boolean,
) => void;
save: (options: object) => Promise<VideoSaveData>;
save: (options: object) => Promise<VideoSaveData> | void;
setVolume: (volume: number) => void;
getCurrentPosition: () => Promise<number>;
setFullScreen: (fullScreen: boolean) => void;
Expand Down

0 comments on commit de81829

Please sign in to comment.