@zezosoft/zezo-ott-react-native-video-player 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/AdsPlayer/store/adsPlayerStore.js +3 -3
- package/lib/module/AdsPlayer/store/adsPlayerStore.js.map +1 -1
- package/lib/module/VideoPlayer/store/videoPlayerStore.js +3 -3
- package/lib/module/VideoPlayer/store/videoPlayerStore.js.map +1 -1
- package/lib/typescript/src/AdsPlayer/store/adsPlayerStore.d.ts +2 -3
- package/lib/typescript/src/AdsPlayer/store/adsPlayerStore.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/store/videoPlayerStore.d.ts +2 -3
- package/lib/typescript/src/VideoPlayer/store/videoPlayerStore.d.ts.map +1 -1
- package/package.json +5 -3
- package/src/AdsPlayer/AdsPlayer.tsx +0 -311
- package/src/AdsPlayer/MediaControls/AdBottomControls.tsx +0 -191
- package/src/AdsPlayer/MediaControls/AdMediaControls.tsx +0 -104
- package/src/AdsPlayer/MediaControls/AdMediaControlsProvider.tsx +0 -62
- package/src/AdsPlayer/MediaControls/AdMiddleControls.tsx +0 -63
- package/src/AdsPlayer/MediaControls/AdTopControls.tsx +0 -191
- package/src/AdsPlayer/MediaControls/index.ts +0 -5
- package/src/AdsPlayer/components/RotatingLoader.tsx +0 -79
- package/src/AdsPlayer/index.ts +0 -4
- package/src/AdsPlayer/store/adsPlayer.type.ts +0 -29
- package/src/AdsPlayer/store/adsPlayerStore.ts +0 -59
- package/src/AdsPlayer/store/index.ts +0 -2
- package/src/AdsPlayer/utils/adStateReset.ts +0 -29
- package/src/AdsPlayer/utils/controls.ts +0 -69
- package/src/AdsPlayer/utils/useAdControlsAutoHide.ts +0 -32
- package/src/AdsPlayer/utils/useAdInitialization.ts +0 -86
- package/src/AdsPlayer/utils/useAdTracking.ts +0 -89
- package/src/AdsPlayer/utils/useAdsManager.ts +0 -215
- package/src/VideoPlayer/MediaControls/BottomControls.tsx +0 -210
- package/src/VideoPlayer/MediaControls/MediaControls.tsx +0 -30
- package/src/VideoPlayer/MediaControls/MediaControlsProvider.tsx +0 -104
- package/src/VideoPlayer/MediaControls/MiddleControls.tsx +0 -259
- package/src/VideoPlayer/MediaControls/TopControls.tsx +0 -100
- package/src/VideoPlayer/Settings/AudioAndSubtitles.tsx +0 -295
- package/src/VideoPlayer/Settings/Episodes.tsx +0 -297
- package/src/VideoPlayer/Settings/SettingModal.tsx +0 -127
- package/src/VideoPlayer/Settings/SpeedControls.tsx +0 -130
- package/src/VideoPlayer/Settings/VideoPlayerSettings.tsx +0 -141
- package/src/VideoPlayer/VideoPlayerCore.tsx +0 -356
- package/src/VideoPlayer/components/ProgressBar.tsx +0 -211
- package/src/VideoPlayer/components/SkipAndNextControls.tsx +0 -192
- package/src/VideoPlayer/components/SubtitleView.tsx +0 -53
- package/src/VideoPlayer/components/Toast.tsx +0 -61
- package/src/VideoPlayer/context/VideoPlayerConfig.tsx +0 -65
- package/src/VideoPlayer/context/index.ts +0 -5
- package/src/VideoPlayer/index.ts +0 -4
- package/src/VideoPlayer/store/index.ts +0 -2
- package/src/VideoPlayer/store/videoPlayer.type.ts +0 -214
- package/src/VideoPlayer/store/videoPlayerStore.ts +0 -97
- package/src/VideoPlayer/styles/globalStyles.ts +0 -73
- package/src/VideoPlayer/utils/display/Display.ts +0 -10
- package/src/VideoPlayer/utils/display/index.ts +0 -1
- package/src/VideoPlayer/utils/format/index.ts +0 -1
- package/src/VideoPlayer/utils/format/timeFormatter.ts +0 -44
- package/src/VideoPlayer/utils/hooks/index.ts +0 -5
- package/src/VideoPlayer/utils/hooks/useAdEventHandler.ts +0 -95
- package/src/VideoPlayer/utils/hooks/useOrientationLock.ts +0 -29
- package/src/VideoPlayer/utils/hooks/usePauseVideoOnAd.ts +0 -46
- package/src/VideoPlayer/utils/hooks/useVideoPlayerBack.ts +0 -66
- package/src/VideoPlayer/utils/hooks/useVideoResolutions.ts +0 -125
- package/src/VideoPlayer/utils/index.ts +0 -6
- package/src/VideoPlayer/utils/platform/PlatformSelector.ts +0 -13
- package/src/VideoPlayer/utils/platform/index.ts +0 -2
- package/src/VideoPlayer/utils/platform/lockOrientation.ts +0 -40
- package/src/VideoPlayer/utils/player/index.ts +0 -2
- package/src/VideoPlayer/utils/player/playerEvents.ts +0 -97
- package/src/VideoPlayer/utils/player/useWatchReporter.ts +0 -105
- package/src/VideoPlayer/utils/video/index.ts +0 -5
- package/src/VideoPlayer/utils/video/videoControl.ts +0 -185
- package/src/VideoPlayer/utils/video/videoRef.ts +0 -21
- package/src/VideoPlayer/utils/video/videoResume.ts +0 -23
- package/src/VideoPlayer/utils/video/videoSource.ts +0 -23
- package/src/VideoPlayer.tsx +0 -181
- package/src/index.tsx +0 -3
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
-
import React, { useEffect, useMemo, useCallback, useRef } from 'react';
|
|
3
|
-
import { View, StyleSheet } from 'react-native';
|
|
4
|
-
import { Slider } from 'react-native-awesome-slider';
|
|
5
|
-
import { useSharedValue, withTiming, Easing } from 'react-native-reanimated';
|
|
6
|
-
import { moderateScale } from 'react-native-size-matters';
|
|
7
|
-
import { useVideoPlayerConfig } from '../context';
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
duration: number;
|
|
11
|
-
currentTime: number;
|
|
12
|
-
bufferedTime: number;
|
|
13
|
-
onSeek?: (time: number) => void;
|
|
14
|
-
showThumb?: boolean;
|
|
15
|
-
height?: number;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
adMarkers?: number[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const SEEK_COOLDOWN_MS = 400;
|
|
21
|
-
const PROGRESS_ANIM_DURATION = 220;
|
|
22
|
-
const CACHE_ANIM_DURATION = 280;
|
|
23
|
-
const SMOOTH_EASING = Easing.bezier(0.25, 0.1, 0.25, 1);
|
|
24
|
-
|
|
25
|
-
const ProgressBar: React.FC<Props> = React.memo(
|
|
26
|
-
({
|
|
27
|
-
duration,
|
|
28
|
-
currentTime,
|
|
29
|
-
bufferedTime,
|
|
30
|
-
onSeek,
|
|
31
|
-
showThumb = true,
|
|
32
|
-
disabled = false,
|
|
33
|
-
adMarkers = [],
|
|
34
|
-
height,
|
|
35
|
-
}) => {
|
|
36
|
-
const { colors, metrics } = useVideoPlayerConfig();
|
|
37
|
-
const sliderHeight = height ?? metrics.sliderHeight;
|
|
38
|
-
const thumbSize = useMemo(() => {
|
|
39
|
-
return sliderHeight * 3;
|
|
40
|
-
}, [sliderHeight]);
|
|
41
|
-
|
|
42
|
-
const progress = useSharedValue(currentTime);
|
|
43
|
-
const cache = useSharedValue(bufferedTime);
|
|
44
|
-
const min = useSharedValue(0);
|
|
45
|
-
const max = useSharedValue(duration);
|
|
46
|
-
|
|
47
|
-
const isSlidingRef = useRef(false);
|
|
48
|
-
const seekCooldownUntilRef = useRef(0);
|
|
49
|
-
const seekCooldownTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(
|
|
50
|
-
null
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (isSlidingRef.current) return;
|
|
55
|
-
if (Date.now() < seekCooldownUntilRef.current) return;
|
|
56
|
-
progress.value = withTiming(currentTime, {
|
|
57
|
-
duration: PROGRESS_ANIM_DURATION,
|
|
58
|
-
easing: SMOOTH_EASING,
|
|
59
|
-
});
|
|
60
|
-
}, [currentTime]);
|
|
61
|
-
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
cache.value = withTiming(bufferedTime, {
|
|
64
|
-
duration: CACHE_ANIM_DURATION,
|
|
65
|
-
easing: SMOOTH_EASING,
|
|
66
|
-
});
|
|
67
|
-
}, [bufferedTime]);
|
|
68
|
-
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
max.value = duration;
|
|
71
|
-
}, [duration]);
|
|
72
|
-
|
|
73
|
-
const adPositions = useMemo(() => {
|
|
74
|
-
if (duration <= 0) return [];
|
|
75
|
-
return adMarkers.map((t) => (t / duration) * 100);
|
|
76
|
-
}, [adMarkers, duration]);
|
|
77
|
-
|
|
78
|
-
const handleSeek = useCallback(
|
|
79
|
-
(value: number) => {
|
|
80
|
-
if (!disabled) onSeek?.(value);
|
|
81
|
-
},
|
|
82
|
-
[onSeek, disabled]
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const handleSlidingStart = useCallback(() => {
|
|
86
|
-
isSlidingRef.current = true;
|
|
87
|
-
if (seekCooldownTimeoutRef.current) {
|
|
88
|
-
clearTimeout(seekCooldownTimeoutRef.current);
|
|
89
|
-
seekCooldownTimeoutRef.current = null;
|
|
90
|
-
}
|
|
91
|
-
}, []);
|
|
92
|
-
|
|
93
|
-
const handleSlidingComplete = useCallback(
|
|
94
|
-
(value: number) => {
|
|
95
|
-
progress.value = value;
|
|
96
|
-
seekCooldownUntilRef.current = Date.now() + SEEK_COOLDOWN_MS;
|
|
97
|
-
seekCooldownTimeoutRef.current = setTimeout(() => {
|
|
98
|
-
isSlidingRef.current = false;
|
|
99
|
-
seekCooldownTimeoutRef.current = null;
|
|
100
|
-
}, SEEK_COOLDOWN_MS);
|
|
101
|
-
},
|
|
102
|
-
[progress]
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
return () => {
|
|
107
|
-
if (seekCooldownTimeoutRef.current) {
|
|
108
|
-
clearTimeout(seekCooldownTimeoutRef.current);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}, []);
|
|
112
|
-
|
|
113
|
-
return (
|
|
114
|
-
<View style={[styles.container, { height: thumbSize }]}>
|
|
115
|
-
<Slider
|
|
116
|
-
progress={progress}
|
|
117
|
-
minimumValue={min}
|
|
118
|
-
maximumValue={max}
|
|
119
|
-
cache={cache}
|
|
120
|
-
disable={disabled}
|
|
121
|
-
onSlidingStart={handleSlidingStart}
|
|
122
|
-
onSlidingComplete={handleSlidingComplete}
|
|
123
|
-
onValueChange={handleSeek}
|
|
124
|
-
containerStyle={[
|
|
125
|
-
styles.sliderContainer,
|
|
126
|
-
{
|
|
127
|
-
borderRadius: sliderHeight / 2,
|
|
128
|
-
height: sliderHeight,
|
|
129
|
-
},
|
|
130
|
-
]}
|
|
131
|
-
renderThumb={
|
|
132
|
-
showThumb
|
|
133
|
-
? () => (
|
|
134
|
-
<View
|
|
135
|
-
style={{
|
|
136
|
-
backgroundColor: colors.primary,
|
|
137
|
-
width: thumbSize,
|
|
138
|
-
height: thumbSize,
|
|
139
|
-
borderRadius: thumbSize / 2,
|
|
140
|
-
}}
|
|
141
|
-
/>
|
|
142
|
-
)
|
|
143
|
-
: () => null
|
|
144
|
-
}
|
|
145
|
-
renderBubble={() => null}
|
|
146
|
-
thumbWidth={showThumb ? thumbSize : 0}
|
|
147
|
-
theme={{
|
|
148
|
-
minimumTrackTintColor: colors.primary,
|
|
149
|
-
maximumTrackTintColor: colors.secondary,
|
|
150
|
-
cacheTrackTintColor: colors.buffer,
|
|
151
|
-
disableMinTrackTintColor: colors.primary,
|
|
152
|
-
bubbleBackgroundColor: colors.white,
|
|
153
|
-
}}
|
|
154
|
-
/>
|
|
155
|
-
|
|
156
|
-
{/* Ad Markers */}
|
|
157
|
-
{adPositions.length > 0 && (
|
|
158
|
-
<View style={styles.adMarkersContainer} pointerEvents="none">
|
|
159
|
-
{adPositions.map((pos, index) => (
|
|
160
|
-
<View
|
|
161
|
-
key={`ad-${index}`}
|
|
162
|
-
style={[
|
|
163
|
-
styles.adMarker,
|
|
164
|
-
{
|
|
165
|
-
left: `${pos}%`,
|
|
166
|
-
backgroundColor: colors.primary,
|
|
167
|
-
width: sliderHeight,
|
|
168
|
-
},
|
|
169
|
-
]}
|
|
170
|
-
/>
|
|
171
|
-
))}
|
|
172
|
-
</View>
|
|
173
|
-
)}
|
|
174
|
-
</View>
|
|
175
|
-
);
|
|
176
|
-
},
|
|
177
|
-
(p, n) =>
|
|
178
|
-
p.currentTime === n.currentTime &&
|
|
179
|
-
p.bufferedTime === n.bufferedTime &&
|
|
180
|
-
p.duration === n.duration &&
|
|
181
|
-
p.disabled === n.disabled &&
|
|
182
|
-
p.showThumb === n.showThumb &&
|
|
183
|
-
p.height === n.height &&
|
|
184
|
-
JSON.stringify(p.adMarkers) === JSON.stringify(n.adMarkers)
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
export default ProgressBar;
|
|
188
|
-
|
|
189
|
-
const styles = StyleSheet.create({
|
|
190
|
-
container: {
|
|
191
|
-
position: 'relative',
|
|
192
|
-
width: '100%',
|
|
193
|
-
overflow: 'hidden',
|
|
194
|
-
justifyContent: 'center',
|
|
195
|
-
},
|
|
196
|
-
sliderContainer: {
|
|
197
|
-
overflow: 'hidden',
|
|
198
|
-
},
|
|
199
|
-
adMarkersContainer: {
|
|
200
|
-
position: 'absolute',
|
|
201
|
-
width: '100%',
|
|
202
|
-
height: '100%',
|
|
203
|
-
justifyContent: 'center',
|
|
204
|
-
},
|
|
205
|
-
adMarker: {
|
|
206
|
-
position: 'absolute',
|
|
207
|
-
aspectRatio: 1,
|
|
208
|
-
top: '50%',
|
|
209
|
-
transform: [{ translateY: -moderateScale(2.5) }],
|
|
210
|
-
},
|
|
211
|
-
});
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
TouchableOpacity,
|
|
4
|
-
View,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
Text,
|
|
7
|
-
type TextStyle,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import Animated, {
|
|
10
|
-
useSharedValue,
|
|
11
|
-
useAnimatedStyle,
|
|
12
|
-
withTiming,
|
|
13
|
-
} from 'react-native-reanimated';
|
|
14
|
-
import { scale } from 'react-native-size-matters';
|
|
15
|
-
import { useVideoPlayerStore } from '../store/videoPlayerStore';
|
|
16
|
-
import { videoRef, Display } from '../utils';
|
|
17
|
-
import { handleNext } from '../utils';
|
|
18
|
-
import type { MediaEpisode } from '../store/videoPlayer.type';
|
|
19
|
-
import { useVideoPlayerConfig } from '../context';
|
|
20
|
-
import type { ExtendedWatchProgress } from '../utils';
|
|
21
|
-
|
|
22
|
-
type SkipAndNextControlsProps = {
|
|
23
|
-
onPressEpisode: ({ episode }: { episode: MediaEpisode }) => Promise<boolean>;
|
|
24
|
-
reportProgress: (event: ExtendedWatchProgress['event']) => void;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const SkipAndNextControls: React.FC<SkipAndNextControlsProps> = ({
|
|
28
|
-
onPressEpisode,
|
|
29
|
-
reportProgress,
|
|
30
|
-
}) => {
|
|
31
|
-
const {
|
|
32
|
-
activeTrack,
|
|
33
|
-
currentTime,
|
|
34
|
-
isSkipIntroVisible,
|
|
35
|
-
isNextEpisodeVisible,
|
|
36
|
-
setIsNextEpisodeVisible,
|
|
37
|
-
setIsSkipIntroVisible,
|
|
38
|
-
settingsModal,
|
|
39
|
-
controlsVisible,
|
|
40
|
-
} = useVideoPlayerStore();
|
|
41
|
-
const { colors } = useVideoPlayerConfig();
|
|
42
|
-
|
|
43
|
-
if (activeTrack?.type !== 'series') return null;
|
|
44
|
-
|
|
45
|
-
const showSkipIntro =
|
|
46
|
-
isSkipIntroVisible &&
|
|
47
|
-
!settingsModal.isVisible &&
|
|
48
|
-
activeTrack.skipIntro &&
|
|
49
|
-
activeTrack.skipIntro.start < currentTime &&
|
|
50
|
-
currentTime < activeTrack.skipIntro.end;
|
|
51
|
-
|
|
52
|
-
const showNextEpisode =
|
|
53
|
-
isNextEpisodeVisible &&
|
|
54
|
-
!settingsModal.isVisible &&
|
|
55
|
-
activeTrack.nextEpisodeAt &&
|
|
56
|
-
activeTrack.nextEpisodeAt < currentTime;
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<>
|
|
60
|
-
{showSkipIntro && (
|
|
61
|
-
<ActionButton
|
|
62
|
-
label="Skip intro"
|
|
63
|
-
onPress={() => {
|
|
64
|
-
if (activeTrack.skipIntro?.end) {
|
|
65
|
-
videoRef?.current?.seek(activeTrack.skipIntro.end);
|
|
66
|
-
}
|
|
67
|
-
}}
|
|
68
|
-
onCancel={() => setIsSkipIntroVisible(false)}
|
|
69
|
-
position="left"
|
|
70
|
-
colors={{ text: colors.black, onBackground: colors.onBackground }}
|
|
71
|
-
controlsVisible={controlsVisible}
|
|
72
|
-
/>
|
|
73
|
-
)}
|
|
74
|
-
|
|
75
|
-
{showNextEpisode && (
|
|
76
|
-
<ActionButton
|
|
77
|
-
label="Next episode"
|
|
78
|
-
onPress={() => {
|
|
79
|
-
reportProgress('EPISODE_CHANGE');
|
|
80
|
-
handleNext({ onPressEpisode, autoNext: true });
|
|
81
|
-
}}
|
|
82
|
-
onCancel={() => setIsNextEpisodeVisible(false)}
|
|
83
|
-
position="right"
|
|
84
|
-
colors={{ text: colors.black, onBackground: colors.onBackground }}
|
|
85
|
-
controlsVisible={controlsVisible}
|
|
86
|
-
/>
|
|
87
|
-
)}
|
|
88
|
-
</>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export default SkipAndNextControls;
|
|
93
|
-
|
|
94
|
-
type ActionButtonColors = {
|
|
95
|
-
text: string;
|
|
96
|
-
onBackground: string;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
type ActionButtonProps = {
|
|
100
|
-
label: string;
|
|
101
|
-
onPress: () => void;
|
|
102
|
-
onCancel: () => void;
|
|
103
|
-
position: 'left' | 'right';
|
|
104
|
-
colors: ActionButtonColors;
|
|
105
|
-
controlsVisible: boolean;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const ActionButton: React.FC<ActionButtonProps> = ({
|
|
109
|
-
label,
|
|
110
|
-
onPress,
|
|
111
|
-
onCancel,
|
|
112
|
-
position,
|
|
113
|
-
colors,
|
|
114
|
-
controlsVisible,
|
|
115
|
-
}) => {
|
|
116
|
-
const opacity = useSharedValue(0);
|
|
117
|
-
const translateY = useSharedValue(10);
|
|
118
|
-
const bottom = useSharedValue(
|
|
119
|
-
controlsVisible ? Display.setHeight(12) : Display.setHeight(10)
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
opacity.value = withTiming(1, { duration: 100 });
|
|
124
|
-
translateY.value = withTiming(0, { duration: 100 });
|
|
125
|
-
}, [opacity, translateY]);
|
|
126
|
-
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
bottom.value = withTiming(
|
|
129
|
-
controlsVisible ? Display.setHeight(12) : Display.setHeight(10),
|
|
130
|
-
{ duration: 100 }
|
|
131
|
-
);
|
|
132
|
-
}, [bottom, controlsVisible]);
|
|
133
|
-
|
|
134
|
-
const animatedStyle = useAnimatedStyle(() => ({
|
|
135
|
-
opacity: opacity.value,
|
|
136
|
-
transform: [{ translateY: translateY.value }],
|
|
137
|
-
bottom: bottom.value,
|
|
138
|
-
}));
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<Animated.View
|
|
142
|
-
style={[
|
|
143
|
-
styles.overlayButton,
|
|
144
|
-
animatedStyle,
|
|
145
|
-
position === 'left' ? { left: scale(58) } : { right: scale(58) },
|
|
146
|
-
]}
|
|
147
|
-
>
|
|
148
|
-
<View style={styles.buttonRow}>
|
|
149
|
-
<TouchableOpacity
|
|
150
|
-
style={[
|
|
151
|
-
styles.actionButton,
|
|
152
|
-
{ backgroundColor: colors.onBackground },
|
|
153
|
-
]}
|
|
154
|
-
onPress={onPress}
|
|
155
|
-
>
|
|
156
|
-
<Text style={makeTextStyle(colors.text)}>{label}</Text>
|
|
157
|
-
</TouchableOpacity>
|
|
158
|
-
<TouchableOpacity
|
|
159
|
-
style={[
|
|
160
|
-
styles.actionButton,
|
|
161
|
-
{ backgroundColor: colors.onBackground },
|
|
162
|
-
]}
|
|
163
|
-
onPress={onCancel}
|
|
164
|
-
>
|
|
165
|
-
<Text style={makeTextStyle(colors.text)}>Cancel</Text>
|
|
166
|
-
</TouchableOpacity>
|
|
167
|
-
</View>
|
|
168
|
-
</Animated.View>
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const styles = StyleSheet.create({
|
|
173
|
-
overlayButton: {
|
|
174
|
-
position: 'absolute', // fixed, not animated
|
|
175
|
-
zIndex: 10,
|
|
176
|
-
},
|
|
177
|
-
buttonRow: {
|
|
178
|
-
flexDirection: 'row',
|
|
179
|
-
gap: scale(10),
|
|
180
|
-
},
|
|
181
|
-
actionButton: {
|
|
182
|
-
paddingHorizontal: scale(20),
|
|
183
|
-
paddingVertical: scale(8),
|
|
184
|
-
borderRadius: scale(8),
|
|
185
|
-
alignSelf: 'flex-start',
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const makeTextStyle = (color: string): TextStyle => ({
|
|
190
|
-
color,
|
|
191
|
-
fontWeight: '600',
|
|
192
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { StyleSheet, View } from 'react-native';
|
|
2
|
-
import { RFValue } from 'react-native-responsive-fontsize';
|
|
3
|
-
import { scale } from 'react-native-size-matters';
|
|
4
|
-
import Subtitles from 'react-native-subtitles';
|
|
5
|
-
import { useVideoPlayerStore } from '../store/videoPlayerStore';
|
|
6
|
-
import { Display } from '../utils';
|
|
7
|
-
import { useVideoPlayerConfig } from '../context';
|
|
8
|
-
|
|
9
|
-
const SubtitleView = () => {
|
|
10
|
-
const { activeSubtitle, currentTime, controlsVisible, settingsModal } =
|
|
11
|
-
useVideoPlayerStore();
|
|
12
|
-
const { colors } = useVideoPlayerConfig();
|
|
13
|
-
if (
|
|
14
|
-
!activeSubtitle ||
|
|
15
|
-
!activeSubtitle.url ||
|
|
16
|
-
controlsVisible ||
|
|
17
|
-
settingsModal.isVisible
|
|
18
|
-
) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return (
|
|
22
|
-
<View style={styles.container}>
|
|
23
|
-
<Subtitles
|
|
24
|
-
containerStyle={styles.subtitleContainer}
|
|
25
|
-
textStyle={{ ...styles.text, color: colors.text }}
|
|
26
|
-
currentTime={currentTime}
|
|
27
|
-
selectedsubtitle={{
|
|
28
|
-
file: activeSubtitle.url,
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
</View>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default SubtitleView;
|
|
36
|
-
|
|
37
|
-
const styles = StyleSheet.create({
|
|
38
|
-
container: {
|
|
39
|
-
width: '100%',
|
|
40
|
-
position: 'absolute',
|
|
41
|
-
bottom: Display.setHeight(3),
|
|
42
|
-
zIndex: 10,
|
|
43
|
-
},
|
|
44
|
-
subtitleContainer: {
|
|
45
|
-
padding: scale(10),
|
|
46
|
-
},
|
|
47
|
-
text: {
|
|
48
|
-
fontSize: RFValue(14),
|
|
49
|
-
paddingHorizontal: scale(10),
|
|
50
|
-
paddingVertical: scale(5),
|
|
51
|
-
borderRadius: scale(5),
|
|
52
|
-
},
|
|
53
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View, Text, StyleSheet } from 'react-native';
|
|
3
|
-
import Animated, { type AnimatedStyle } from 'react-native-reanimated';
|
|
4
|
-
import { type EdgeInsets } from 'react-native-safe-area-context';
|
|
5
|
-
import { scale } from 'react-native-size-matters';
|
|
6
|
-
import { useVideoPlayerConfig } from '../context';
|
|
7
|
-
|
|
8
|
-
export interface ToastProps {
|
|
9
|
-
message: string;
|
|
10
|
-
animatedStyle: AnimatedStyle<any>;
|
|
11
|
-
insets: EdgeInsets;
|
|
12
|
-
position?: 'top' | 'bottom';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const Toast: React.FC<ToastProps> = ({
|
|
16
|
-
message,
|
|
17
|
-
animatedStyle,
|
|
18
|
-
insets,
|
|
19
|
-
position = 'top',
|
|
20
|
-
}) => {
|
|
21
|
-
const { colors } = useVideoPlayerConfig();
|
|
22
|
-
|
|
23
|
-
const containerStyle = [
|
|
24
|
-
styles.container,
|
|
25
|
-
position === 'top'
|
|
26
|
-
? { top: (insets.top || 0) + scale(6) }
|
|
27
|
-
: { bottom: (insets.bottom || 0) + scale(6) },
|
|
28
|
-
animatedStyle,
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Animated.View style={containerStyle}>
|
|
33
|
-
<View style={styles.toast}>
|
|
34
|
-
<Text style={[styles.text, { color: colors.text }]}>{message}</Text>
|
|
35
|
-
</View>
|
|
36
|
-
</Animated.View>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const styles = StyleSheet.create({
|
|
41
|
-
container: {
|
|
42
|
-
position: 'absolute',
|
|
43
|
-
alignSelf: 'center',
|
|
44
|
-
zIndex: 1000,
|
|
45
|
-
},
|
|
46
|
-
toast: {
|
|
47
|
-
paddingHorizontal: scale(12),
|
|
48
|
-
paddingVertical: scale(6),
|
|
49
|
-
borderRadius: scale(4),
|
|
50
|
-
minWidth: scale(80),
|
|
51
|
-
alignItems: 'center',
|
|
52
|
-
justifyContent: 'center',
|
|
53
|
-
backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
|
54
|
-
},
|
|
55
|
-
text: {
|
|
56
|
-
fontSize: scale(12),
|
|
57
|
-
fontWeight: '600',
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export default Toast;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, type ReactNode } from 'react';
|
|
2
|
-
import { scale } from 'react-native-size-matters';
|
|
3
|
-
|
|
4
|
-
export interface VideoPlayerTheme {
|
|
5
|
-
colors: {
|
|
6
|
-
primary: string;
|
|
7
|
-
secondary: string;
|
|
8
|
-
background: string;
|
|
9
|
-
onBackground: string;
|
|
10
|
-
text: string;
|
|
11
|
-
white: string;
|
|
12
|
-
black: string;
|
|
13
|
-
track: string;
|
|
14
|
-
buffer: string;
|
|
15
|
-
};
|
|
16
|
-
metrics: {
|
|
17
|
-
thumbSize: number;
|
|
18
|
-
sliderHeight: number;
|
|
19
|
-
controlSize: number;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const defaultTheme: VideoPlayerTheme = {
|
|
24
|
-
colors: {
|
|
25
|
-
primary: '#ff0000',
|
|
26
|
-
secondary: '#999999',
|
|
27
|
-
background: '#000000',
|
|
28
|
-
onBackground: '#E2E8F0',
|
|
29
|
-
text: '#ffffff',
|
|
30
|
-
white: '#ffffff',
|
|
31
|
-
black: '#000000',
|
|
32
|
-
track: '#868686f0',
|
|
33
|
-
buffer: '#ffffffd1',
|
|
34
|
-
},
|
|
35
|
-
metrics: {
|
|
36
|
-
thumbSize: scale(14),
|
|
37
|
-
sliderHeight: scale(4),
|
|
38
|
-
controlSize: scale(28),
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const VideoPlayerConfigContext = createContext<VideoPlayerTheme>(defaultTheme);
|
|
43
|
-
|
|
44
|
-
export const VideoPlayerConfigProvider = ({
|
|
45
|
-
children,
|
|
46
|
-
theme,
|
|
47
|
-
}: {
|
|
48
|
-
children: ReactNode;
|
|
49
|
-
theme?: Partial<VideoPlayerTheme>;
|
|
50
|
-
}) => {
|
|
51
|
-
const mergedTheme: VideoPlayerTheme = {
|
|
52
|
-
...defaultTheme,
|
|
53
|
-
...theme,
|
|
54
|
-
colors: { ...defaultTheme.colors, ...theme?.colors },
|
|
55
|
-
metrics: { ...defaultTheme.metrics, ...theme?.metrics },
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<VideoPlayerConfigContext.Provider value={mergedTheme}>
|
|
60
|
-
{children}
|
|
61
|
-
</VideoPlayerConfigContext.Provider>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const useVideoPlayerConfig = () => useContext(VideoPlayerConfigContext);
|
package/src/VideoPlayer/index.ts
DELETED