UNPKG

2.73 kBPlain TextView Raw
1import * as React from 'react';
2import { ImageProps, View } from 'react-native';
3
4import {
5 AVPlaybackNativeSource,
6 AVPlaybackSource,
7 AVPlaybackStatus,
8 AVPlaybackStatusToSet,
9} from './AV';
10
11export type VideoNaturalSize = {
12 width: number;
13 height: number;
14 orientation: 'portrait' | 'landscape';
15};
16
17export enum ResizeMode {
18 CONTAIN = 'contain',
19 COVER = 'cover',
20 STRETCH = 'stretch',
21}
22
23export type VideoReadyForDisplayEvent = {
24 naturalSize: VideoNaturalSize;
25 status: AVPlaybackStatus;
26};
27
28export type VideoFullscreenUpdateEvent = {
29 fullscreenUpdate: 0 | 1 | 2 | 3;
30 status: AVPlaybackStatus;
31};
32
33export type VideoProps = {
34 // Source stuff
35 source?: AVPlaybackSource; // { uri: 'http://foo/bar.mp4' }, Asset, or require('./foo/bar.mp4')
36 posterSource?: ImageProps['source']; // { uri: 'http://foo/bar.mp4' } or require('./foo/bar.mp4')
37 posterStyle?: ImageProps['style'];
38
39 // Callbacks
40 onPlaybackStatusUpdate?: (status: AVPlaybackStatus) => void;
41 onLoadStart?: () => void;
42 onLoad?: (status: AVPlaybackStatus) => void;
43 onError?: (error: string) => void;
44 onReadyForDisplay?: (event: VideoReadyForDisplayEvent) => void;
45 onFullscreenUpdate?: (event: VideoFullscreenUpdateEvent) => void;
46 onIOSFullscreenUpdate?: (event: VideoFullscreenUpdateEvent) => void;
47
48 // UI stuff
49 useNativeControls?: boolean;
50 // NOTE(ide): This should just be ResizeMode. We have the explicit strings for now since we don't
51 // currently the ResizeMode enum.
52 resizeMode?: ResizeMode | 'stretch' | 'cover' | 'contain';
53 usePoster?: boolean;
54
55 // Playback API
56 status?: AVPlaybackStatusToSet;
57 progressUpdateIntervalMillis?: number;
58 positionMillis?: number;
59 shouldPlay?: boolean;
60 rate?: number;
61 shouldCorrectPitch?: boolean;
62 volume?: number;
63 isMuted?: boolean;
64 isLooping?: boolean;
65
66 // Required by react-native
67 scaleX?: number;
68 scaleY?: number;
69 translateX?: number;
70 translateY?: number;
71 rotation?: number;
72} & React.ComponentProps<typeof View>;
73
74export type VideoNativeProps = {
75 source?: AVPlaybackNativeSource | null;
76 resizeMode?: unknown;
77 status?: AVPlaybackStatusToSet;
78 onLoadStart?: () => void;
79 onLoad?: (event: { nativeEvent: AVPlaybackStatus }) => void;
80 onError?: (event: { nativeEvent: { error: string } }) => void;
81 onStatusUpdate?: (event: { nativeEvent: AVPlaybackStatus }) => void;
82 onReadyForDisplay?: (event: { nativeEvent: VideoReadyForDisplayEvent }) => void;
83 onFullscreenUpdate?: (event: { nativeEvent: VideoFullscreenUpdateEvent }) => void;
84 useNativeControls?: boolean;
85} & React.ComponentProps<typeof View>;
86
87export type VideoState = {
88 showPoster: boolean;
89};
90export type ExponentVideoComponent = React.ComponentClass<VideoNativeProps>;