Skip to content

Commit

Permalink
chore(sample): additionnal sample cleanup (#4122)
Browse files Browse the repository at this point in the history
* chore: move MultiValueControl & toggleControl to component
* fix(sample): fix import / export to avoid circular deps
* chore(sample): fix warning
  • Loading branch information
freeboub authored Aug 31, 2024
1 parent 451806c commit fb3c0da
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface MultiValueControlType<T> {
onPress: (arg: T) => void;
}

const MultiValueControl = <T extends number | string | ResizeMode>({
export const MultiValueControl = <T extends number | string | ResizeMode>({
values,
selected,
onPress,
Expand Down
19 changes: 9 additions & 10 deletions examples/basic/src/components/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import React, {
} from 'react';
import {View} from 'react-native';
import styles from '../styles.tsx';
import ToggleControl from '../ToggleControl.tsx';
import {isAndroid, isIos, textTracksSelectionBy} from '../constants';
import MultiValueControl from '../MultiValueControl.tsx';
import {
ResizeMode,
VideoRef,
Expand All @@ -23,14 +21,15 @@ import {
type VideoTrack,
type AudioTrack,
} from 'react-native-video';
import {
toast,
Seeker,
AudioTrackSelector,
TextTrackSelector,
VideoTrackSelector,
TopControl,
} from '../components';

import {toast} from './Toast';
import {Seeker} from './Seeker';
import {AudioTrackSelector} from './AudioTracksSelector';
import {VideoTrackSelector} from './VideoTracksSelector';
import {TextTrackSelector} from './TextTracksSelector';
import {TopControl} from './TopControl';
import {ToggleControl} from './ToggleControl';
import {MultiValueControl} from './MultiValueControl';

type Props = {
channelDown: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface ToggleControlType {
onPress: () => void;
}

const ToggleControl = ({
export const ToggleControl = ({
isSelected,
selectedText,
unselectedText,
Expand Down
2 changes: 2 additions & 0 deletions examples/basic/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ export * from './TextTracksSelector';
export * from './Overlay';
export * from './TopControl';
export * from './Toast';
export * from './ToggleControl';
export * from './MultiValueControl';
13 changes: 8 additions & 5 deletions examples/basic/src/constants/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ export const srcAllPlatformList = [
},
];

export const srcIosList = [];
export const srcIosList: SampleVideoSource[] = [];

export const srcAndroidList = [
export const srcAndroidList: SampleVideoSource[] = [
{
description: 'Another live sample',
uri: 'https://live.forstreet.cl/live/livestream.m3u8',
Expand Down Expand Up @@ -149,9 +149,12 @@ export const srcAndroidList = [
},
];

export const srcList: SampleVideoSource[] = srcAllPlatformList.concat(
isAndroid ? srcAndroidList : srcIosList,
);
const platformSrc: SampleVideoSource[] = isAndroid
? srcAndroidList
: srcIosList;

export const srcList: SampleVideoSource[] =
platformSrc.concat(srcAllPlatformList);

export const bufferConfig: BufferConfig = {
minBufferMs: 15000,
Expand Down
10 changes: 5 additions & 5 deletions examples/basic/src/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {Drm, ReactVideoSource, TextTracks} from 'react-native-video';

export type AdditionalSourceInfo = {
textTracks: TextTracks;
adTagUrl: string;
description: string;
drm: Drm;
noView: boolean;
textTracks?: TextTracks;
adTagUrl?: string;
description?: string;
drm?: Drm;
noView?: boolean;
};

export type SampleVideoSource = ReactVideoSource | AdditionalSourceInfo;

0 comments on commit fb3c0da

Please sign in to comment.