-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathprops.tsx
124 lines (120 loc) · 3.21 KB
/
props.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { AVPlaybackStatus, Video, VideoProps } from 'expo-av'
import { ActivityIndicatorProps, Dimensions, Platform, TextStyle } from 'react-native'
import { ColorValue } from 'react-native'
import { ErrorType } from './constants'
import { MutableRefObject, ReactNode } from 'react'
import { SliderProps } from '@react-native-community/slider'
// https://github.com/typescript-cheatsheets/react/issues/415
export type Props = RequiredProps & DefaultProps
export const defaultProps = {
errorCallback: error =>
console.error(`[VideoPlayer] ${error.type} Error - ${error.message}: ${error.obj}`),
// eslint-disable-next-line @typescript-eslint/no-empty-function
playbackCallback: () => {},
defaultControlsVisible: false,
timeVisible: true,
slider: {
visible: true,
},
textStyle: {
color: '#FFF',
fontSize: 12,
textAlign: 'center',
},
activityIndicator: {
size: 'large',
color: '#999',
},
animation: {
fadeInDuration: 300,
fadeOutDuration: 300,
},
style: {
width: Platform.OS === 'web' ? '100%' : Dimensions.get('window').width,
height: Dimensions.get('window').height,
videoBackgroundColor: '#000',
controlsBackgroundColor: '#000',
},
icon: {
size: 48,
color: '#FFF',
style: {
padding: 2,
},
},
fullscreen: {
enterFullscreen: () =>
// eslint-disable-next-line no-console
console.log('[VideoPlayer] - missing `enterFullscreen` function in `fullscreen` prop'),
exitFullscreen: () =>
// eslint-disable-next-line no-console
console.log('[VideoPlayer] - missing `exitFullscreen` function in `fullscreen` prop'),
inFullscreen: false,
visible: true,
},
autoHidePlayer: true,
header: undefined,
mute: {
enterMute: () =>
// eslint-disable-next-line no-console
console.log('[VideoPlayer] - missing `enterMute` function in `mute` prop'),
exitMute: () =>
// eslint-disable-next-line no-console
console.log('[VideoPlayer] - missing `exitMute` function in `mute` prop'),
isMute: false,
visible: false,
},
} as DefaultProps
type RequiredProps = {
videoProps: VideoProps & {
ref?: MutableRefObject<Video>
}
}
type DefaultProps = {
errorCallback: (error: ErrorType) => void
playbackCallback: (status: AVPlaybackStatus) => void
defaultControlsVisible: boolean
timeVisible: boolean
textStyle: TextStyle
slider: {
visible?: boolean
} & SliderProps
activityIndicator: ActivityIndicatorProps
animation: {
fadeInDuration?: number
fadeOutDuration?: number
}
header: ReactNode
style: {
width?: number
height?: number
videoBackgroundColor?: ColorValue
controlsBackgroundColor?: ColorValue
}
icon: {
size?: number
color?: ColorValue
style?: TextStyle
pause?: JSX.Element
play?: JSX.Element
replay?: JSX.Element
loading?: JSX.Element
fullscreen?: JSX.Element
exitFullscreen?: JSX.Element
mute?: JSX.Element
exitMute?: JSX.Element
}
fullscreen: {
enterFullscreen?: () => void
exitFullscreen?: () => void
inFullscreen?: boolean
visible?: boolean
}
autoHidePlayer: boolean
mute: {
enterMute?: () => void
exitMute?: () => void
isMute?: boolean
visible?: boolean
}
}