@umituz/react-native-video-editor 1.0.10 → 1.0.11
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-video-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Professional video editor with layer-based timeline, text/image/shape/audio/animation layers, and export functionality",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -8,17 +8,31 @@ import {
|
|
|
8
8
|
View,
|
|
9
9
|
TouchableOpacity,
|
|
10
10
|
StyleSheet,
|
|
11
|
-
|
|
11
|
+
type ViewStyle,
|
|
12
12
|
} from "react-native";
|
|
13
13
|
import { Image } from "expo-image";
|
|
14
14
|
import { VideoView } from "expo-video";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
useAppDesignTokens,
|
|
17
|
+
AtomicIcon,
|
|
18
|
+
useResponsive,
|
|
19
|
+
} from "@umituz/react-native-design-system";
|
|
16
20
|
|
|
17
21
|
import type { VideoPlayerProps } from "../../types";
|
|
18
22
|
import { useVideoPlayerControl } from "../hooks/useVideoPlayerControl";
|
|
19
23
|
|
|
24
|
+
declare const __DEV__: boolean;
|
|
25
|
+
|
|
20
26
|
const ASPECT_RATIO = 16 / 9;
|
|
21
27
|
|
|
28
|
+
/** Extract numeric width from style prop */
|
|
29
|
+
const getWidthFromStyle = (style: ViewStyle | undefined): number | null => {
|
|
30
|
+
if (!style) return null;
|
|
31
|
+
const w = style.width;
|
|
32
|
+
if (typeof w === "number") return w;
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
|
|
22
36
|
export const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
|
23
37
|
source,
|
|
24
38
|
thumbnailUrl,
|
|
@@ -30,10 +44,9 @@ export const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
|
|
30
44
|
style,
|
|
31
45
|
}) => {
|
|
32
46
|
const tokens = useAppDesignTokens();
|
|
33
|
-
const { width } =
|
|
47
|
+
const { width: screenWidth, horizontalPadding } = useResponsive();
|
|
34
48
|
const [showVideo, setShowVideo] = useState(autoPlay);
|
|
35
49
|
|
|
36
|
-
// Always pass source to player - control visibility separately
|
|
37
50
|
const { player, state, controls } = useVideoPlayerControl({
|
|
38
51
|
source,
|
|
39
52
|
loop,
|
|
@@ -41,47 +54,55 @@ export const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
|
|
41
54
|
autoPlay: false,
|
|
42
55
|
});
|
|
43
56
|
|
|
44
|
-
// Auto-play when user clicks play button
|
|
45
57
|
useEffect(() => {
|
|
46
58
|
if (showVideo && state.isPlayerValid && player) {
|
|
47
|
-
|
|
59
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
60
|
+
// eslint-disable-next-line no-console
|
|
61
|
+
console.log("[VideoPlayer] Starting playback...");
|
|
62
|
+
}
|
|
48
63
|
controls.play();
|
|
49
64
|
}
|
|
50
65
|
}, [showVideo, state.isPlayerValid, player, controls]);
|
|
51
66
|
|
|
52
67
|
const handlePlay = useCallback(() => {
|
|
53
|
-
|
|
68
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.log("[VideoPlayer] handlePlay called, source:", source);
|
|
71
|
+
}
|
|
54
72
|
setShowVideo(true);
|
|
55
73
|
}, [source]);
|
|
56
74
|
|
|
75
|
+
// Calculate absolute dimensions for VideoView (expo-video requires pixel values)
|
|
76
|
+
const videoWidth = getWidthFromStyle(style as ViewStyle) ?? (screenWidth - horizontalPadding * 2);
|
|
77
|
+
const videoHeight = videoWidth / ASPECT_RATIO;
|
|
78
|
+
|
|
57
79
|
const containerStyle = useMemo(() => ({
|
|
58
|
-
width:
|
|
59
|
-
|
|
80
|
+
width: videoWidth,
|
|
81
|
+
height: videoHeight,
|
|
60
82
|
backgroundColor: tokens.colors.surface,
|
|
61
83
|
borderRadius: 16,
|
|
62
84
|
overflow: "hidden" as const,
|
|
63
|
-
}), [tokens.colors.surface]);
|
|
85
|
+
}), [tokens.colors.surface, videoWidth, videoHeight]);
|
|
64
86
|
|
|
65
87
|
const styles = useMemo(
|
|
66
88
|
() =>
|
|
67
89
|
StyleSheet.create({
|
|
68
90
|
video: {
|
|
69
|
-
width:
|
|
70
|
-
height:
|
|
91
|
+
width: videoWidth,
|
|
92
|
+
height: videoHeight,
|
|
71
93
|
},
|
|
72
94
|
thumbnailContainer: {
|
|
73
|
-
|
|
74
|
-
height: "100%",
|
|
95
|
+
flex: 1,
|
|
75
96
|
justifyContent: "center",
|
|
76
97
|
alignItems: "center",
|
|
77
98
|
},
|
|
78
99
|
thumbnail: {
|
|
79
|
-
width:
|
|
80
|
-
height:
|
|
100
|
+
width: videoWidth,
|
|
101
|
+
height: videoHeight,
|
|
81
102
|
},
|
|
82
103
|
placeholder: {
|
|
83
|
-
width:
|
|
84
|
-
height:
|
|
104
|
+
width: videoWidth,
|
|
105
|
+
height: videoHeight,
|
|
85
106
|
backgroundColor: tokens.colors.surfaceSecondary,
|
|
86
107
|
},
|
|
87
108
|
playButtonContainer: {
|
|
@@ -99,20 +120,24 @@ export const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
|
|
99
120
|
paddingLeft: 4,
|
|
100
121
|
},
|
|
101
122
|
}),
|
|
102
|
-
[tokens]
|
|
123
|
+
[tokens, videoWidth, videoHeight]
|
|
103
124
|
);
|
|
104
125
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
126
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
127
|
+
// eslint-disable-next-line no-console
|
|
128
|
+
console.log("[VideoPlayer] state:", {
|
|
129
|
+
showVideo,
|
|
130
|
+
isPlayerValid: state.isPlayerValid,
|
|
131
|
+
hasPlayer: !!player,
|
|
132
|
+
source,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
112
135
|
|
|
113
|
-
// Show video player when playing
|
|
114
136
|
if (showVideo && state.isPlayerValid && player) {
|
|
115
|
-
|
|
137
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
138
|
+
// eslint-disable-next-line no-console
|
|
139
|
+
console.log("[VideoPlayer] Rendering VideoView");
|
|
140
|
+
}
|
|
116
141
|
return (
|
|
117
142
|
<View style={[containerStyle, style]}>
|
|
118
143
|
<VideoView
|
|
@@ -125,7 +150,6 @@ export const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
|
|
125
150
|
);
|
|
126
151
|
}
|
|
127
152
|
|
|
128
|
-
// Show thumbnail with play button
|
|
129
153
|
return (
|
|
130
154
|
<TouchableOpacity
|
|
131
155
|
style={[containerStyle, style]}
|