@mpxjs/webpack-plugin 2.9.73 → 2.10.0
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/file-loader.js +5 -0
- package/lib/index.js +21 -3
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/platform/template/wx/component-config/video.js +28 -1
- package/lib/platform/template/wx/index.js +2 -2
- package/lib/react/processScript.js +6 -4
- package/lib/react/processTemplate.js +5 -3
- package/lib/runtime/components/react/KeyboardAvoidingView.tsx +108 -0
- package/lib/runtime/components/react/context.ts +18 -2
- package/lib/runtime/components/react/dist/KeyboardAvoidingView.jsx +89 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +1 -2
- package/lib/runtime/components/react/dist/mpx-button.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-icon/icons/cancel.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/clear.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/download.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/info.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/search.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/success.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/success_no_circle.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/waiting.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/warn.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +50 -0
- package/lib/runtime/components/react/dist/mpx-image.jsx +19 -18
- package/lib/runtime/components/react/dist/mpx-input.jsx +48 -19
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +16 -14
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.jsx +30 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.jsx +112 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +41 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +19 -7
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +11 -3
- package/lib/runtime/components/react/dist/mpx-video.jsx +248 -0
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +149 -50
- package/lib/runtime/components/react/dist/useAnimationHooks.js +4 -4
- package/lib/runtime/components/react/dist/utils.jsx +8 -3
- package/lib/runtime/components/react/getInnerListeners.ts +1 -2
- package/lib/runtime/components/react/mpx-button.tsx +1 -1
- package/lib/runtime/components/react/mpx-icon/icons/cancel.png +0 -0
- package/lib/runtime/components/react/mpx-icon/icons/clear.png +0 -0
- package/lib/runtime/components/react/mpx-icon/icons/download.png +0 -0
- package/lib/runtime/components/react/mpx-icon/icons/info.png +0 -0
- package/lib/runtime/components/react/mpx-icon/icons/search.png +0 -0
- package/lib/runtime/components/react/mpx-icon/icons/success.png +0 -0
- package/lib/runtime/components/react/mpx-icon/icons/success_no_circle.png +0 -0
- package/lib/runtime/components/react/mpx-icon/icons/waiting.png +0 -0
- package/lib/runtime/components/react/mpx-icon/icons/warn.png +0 -0
- package/lib/runtime/components/react/mpx-icon/index.tsx +111 -0
- package/lib/runtime/components/react/mpx-image.tsx +26 -14
- package/lib/runtime/components/react/mpx-input.tsx +52 -20
- package/lib/runtime/components/react/mpx-movable-view.tsx +19 -16
- package/lib/runtime/components/react/mpx-picker/time.tsx +2 -1
- package/lib/runtime/components/react/mpx-portal/index.tsx +39 -0
- package/lib/runtime/components/react/mpx-portal/portal-host.tsx +141 -0
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +64 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +1 -1
- package/lib/runtime/components/react/mpx-scroll-view.tsx +20 -8
- package/lib/runtime/components/react/mpx-swiper.tsx +3 -2
- package/lib/runtime/components/react/mpx-textarea.tsx +13 -3
- package/lib/runtime/components/react/mpx-video.tsx +388 -0
- package/lib/runtime/components/react/mpx-web-view.tsx +180 -49
- package/lib/runtime/components/react/types/getInnerListeners.d.ts +1 -1
- package/lib/runtime/components/react/types/global.d.ts +8 -0
- package/lib/runtime/components/react/useAnimationHooks.ts +4 -4
- package/lib/runtime/components/react/utils.tsx +12 -6
- package/lib/script-setup-compiler/index.js +6 -2
- package/lib/style-compiler/index.js +3 -4
- package/lib/style-compiler/strip-conditional-loader.js +127 -0
- package/lib/template-compiler/compiler.js +15 -8
- package/lib/template-compiler/index.js +4 -4
- package/lib/web/processTemplate.js +7 -5
- package/lib/wxs/loader.js +2 -2
- package/lib/wxs/pre-loader.js +2 -2
- package/package.json +7 -5
- package/lib/runtime/components/react/dist/mpx-icon.jsx +0 -41
- package/lib/runtime/components/react/mpx-icon.tsx +0 -102
|
@@ -340,11 +340,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
340
340
|
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
341
341
|
onStartReached(e)
|
|
342
342
|
onEndReached(e)
|
|
343
|
-
|
|
344
|
-
for (const key in intersectionObservers) {
|
|
345
|
-
intersectionObservers[key].throttleMeasure()
|
|
346
|
-
}
|
|
347
|
-
}
|
|
343
|
+
updateIntersection()
|
|
348
344
|
}
|
|
349
345
|
|
|
350
346
|
function onScrollEnd (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
@@ -366,8 +362,15 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
366
362
|
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
367
363
|
onStartReached(e)
|
|
368
364
|
onEndReached(e)
|
|
365
|
+
updateIntersection()
|
|
366
|
+
}
|
|
367
|
+
function updateIntersection () {
|
|
368
|
+
if (enableTriggerIntersectionObserver && intersectionObservers) {
|
|
369
|
+
for (const key in intersectionObservers) {
|
|
370
|
+
intersectionObservers[key].throttleMeasure()
|
|
371
|
+
}
|
|
372
|
+
}
|
|
369
373
|
}
|
|
370
|
-
|
|
371
374
|
function scrollToOffset (x = 0, y = 0) {
|
|
372
375
|
if (scrollViewRef.current) {
|
|
373
376
|
scrollViewRef.current.scrollTo({ x, y, animated: !!scrollWithAnimation })
|
|
@@ -437,12 +440,21 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
437
440
|
function onScrollDrag (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
438
441
|
const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset
|
|
439
442
|
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
443
|
+
updateIntersection()
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function onScrollDragStart (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
447
|
+
hasCallScrollToLower.current = false
|
|
448
|
+
hasCallScrollToUpper.current = false
|
|
449
|
+
onScrollDrag(e)
|
|
440
450
|
}
|
|
441
451
|
|
|
442
452
|
const scrollAdditionalProps: ScrollAdditionalProps = extendObject(
|
|
443
453
|
{
|
|
444
454
|
style: extendObject({}, innerStyle, layoutStyle),
|
|
445
455
|
pinchGestureEnabled: false,
|
|
456
|
+
alwaysBounceVertical: false,
|
|
457
|
+
alwaysBounceHorizontal: false,
|
|
446
458
|
horizontal: scrollX && !scrollY,
|
|
447
459
|
scrollEventThrottle: scrollEventThrottle,
|
|
448
460
|
scrollsToTop: enableBackToTop,
|
|
@@ -453,9 +465,9 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
453
465
|
onScroll: onScroll,
|
|
454
466
|
onContentSizeChange: onContentSizeChange,
|
|
455
467
|
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
|
|
456
|
-
bindtouchmove: ((enhanced && binddragging) ||
|
|
468
|
+
bindtouchmove: ((enhanced && binddragging) || bindtouchmove) && onScrollTouchMove,
|
|
457
469
|
bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
|
|
458
|
-
onScrollBeginDrag:
|
|
470
|
+
onScrollBeginDrag: onScrollDragStart,
|
|
459
471
|
onScrollEndDrag: onScrollDrag,
|
|
460
472
|
onMomentumScrollEnd: onScrollEnd
|
|
461
473
|
},
|
|
@@ -117,7 +117,7 @@ const activeDotStyle = {
|
|
|
117
117
|
const longPressRatio = 100
|
|
118
118
|
|
|
119
119
|
const easeMap = {
|
|
120
|
-
default: Easing.
|
|
120
|
+
default: Easing.inOut(Easing.cubic),
|
|
121
121
|
linear: Easing.linear,
|
|
122
122
|
easeInCubic: Easing.in(Easing.cubic),
|
|
123
123
|
easeOutCubic: Easing.out(Easing.cubic),
|
|
@@ -497,7 +497,8 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
497
497
|
let isCriticalItem = false
|
|
498
498
|
// 真实滚动到的偏移量坐标
|
|
499
499
|
let moveToTargetPos = 0
|
|
500
|
-
const
|
|
500
|
+
const tmp = !circularShared.value ? 0 : preMarginShared.value
|
|
501
|
+
const currentOffset = translation < 0 ? offset.value - tmp : offset.value + tmp
|
|
501
502
|
const computedIndex = Math.abs(currentOffset) / step.value
|
|
502
503
|
const moveToIndex = translation < 0 ? Math.ceil(computedIndex) : Math.floor(computedIndex)
|
|
503
504
|
// 实际应该定位的索引值
|
|
@@ -20,11 +20,17 @@ export type TextareProps = Omit<
|
|
|
20
20
|
'type' | 'password' | 'multiline' | 'confirm-hold'
|
|
21
21
|
>
|
|
22
22
|
|
|
23
|
+
const DEFAULT_TEXTAREA_WIDTH = 300
|
|
24
|
+
const DEFAULT_TEXTAREA_HEIGHT = 150
|
|
25
|
+
|
|
23
26
|
const Textarea = forwardRef<HandlerRef<TextInput, TextareProps>, TextareProps>(
|
|
24
27
|
(props, ref): JSX.Element => {
|
|
28
|
+
const { style = {} } = props
|
|
29
|
+
|
|
25
30
|
const restProps = omit(props, [
|
|
26
31
|
'ref',
|
|
27
32
|
'type',
|
|
33
|
+
'style',
|
|
28
34
|
'password',
|
|
29
35
|
'multiline',
|
|
30
36
|
'confirm-hold'
|
|
@@ -32,12 +38,16 @@ const Textarea = forwardRef<HandlerRef<TextInput, TextareProps>, TextareProps>(
|
|
|
32
38
|
|
|
33
39
|
return createElement(
|
|
34
40
|
Input,
|
|
35
|
-
extendObject({
|
|
41
|
+
extendObject(restProps, {
|
|
36
42
|
ref: ref,
|
|
37
43
|
multiline: true,
|
|
38
44
|
confirmType: 'next',
|
|
39
|
-
bindblur: () => Keyboard.dismiss()
|
|
40
|
-
|
|
45
|
+
bindblur: () => Keyboard.dismiss(),
|
|
46
|
+
style: extendObject({
|
|
47
|
+
width: DEFAULT_TEXTAREA_WIDTH,
|
|
48
|
+
height: DEFAULT_TEXTAREA_HEIGHT
|
|
49
|
+
}, style)
|
|
50
|
+
})
|
|
41
51
|
)
|
|
42
52
|
}
|
|
43
53
|
)
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✔ src
|
|
3
|
+
* ✘ duration
|
|
4
|
+
* ✔ controls
|
|
5
|
+
* ✘ danmu-list
|
|
6
|
+
* ✘ danmu-btn
|
|
7
|
+
* ✘ enable-danmu
|
|
8
|
+
* ✔ autoplay
|
|
9
|
+
* ✔ loop
|
|
10
|
+
* ✔ muted
|
|
11
|
+
* ✔ initial-time
|
|
12
|
+
* ✘ page-gesture
|
|
13
|
+
* ✘ direction
|
|
14
|
+
* ✘ show-progress
|
|
15
|
+
* ✘ show-fullscreen-btn
|
|
16
|
+
* ✘ show-play-btn
|
|
17
|
+
* ✘ show-center-play-btn
|
|
18
|
+
* ✘ enable-progress-gesture
|
|
19
|
+
* ✔ object-fit
|
|
20
|
+
* ✔ poster
|
|
21
|
+
* ✘ show-mute-btn
|
|
22
|
+
* ✘ title
|
|
23
|
+
* ✘ play-btn-position
|
|
24
|
+
* ✘ enable-play-gesture
|
|
25
|
+
* ✘ auto-pause-if-navigate
|
|
26
|
+
* ✘ auto-pause-if-open-native
|
|
27
|
+
* ✘ vslide-gesture
|
|
28
|
+
* ✘ vslide-gesture-in-fullscreen
|
|
29
|
+
* ✘ show-bottom-progress(use show-progress)
|
|
30
|
+
* ✘ ad-unit-id
|
|
31
|
+
* ✘ poster-for-crawler
|
|
32
|
+
* ✘ show-casting-button
|
|
33
|
+
* ✘ picture-in-picture-mode
|
|
34
|
+
* ✘ picture-in-picture-show-progress
|
|
35
|
+
* ✘ picture-in-picture-init-position
|
|
36
|
+
* ✔ enable-auto-rotation (only ios)
|
|
37
|
+
* ✘ show-screen-lock-button
|
|
38
|
+
* ✘ show-snapshot-button
|
|
39
|
+
* ✘ show-background-playback-button
|
|
40
|
+
* ✘ background-poster
|
|
41
|
+
* ✘ referrer-policy
|
|
42
|
+
* ✔ is-drm
|
|
43
|
+
* ✘ is-live
|
|
44
|
+
* ✔ provision-url(android)
|
|
45
|
+
* ✔ certificate-url(ios)
|
|
46
|
+
* ✔ license-url
|
|
47
|
+
* ✔ preferred-peak-bit-rate
|
|
48
|
+
* ✔ bindplay
|
|
49
|
+
* ✔ bindpause
|
|
50
|
+
* ✔ bindended
|
|
51
|
+
* ✘ bindtimeupdate
|
|
52
|
+
* ✔ bindfullscreenchange
|
|
53
|
+
* ✔ bindwaiting
|
|
54
|
+
* ✔ binderror
|
|
55
|
+
* ✘ bindprogress
|
|
56
|
+
* ✔ bindloadedmetadata
|
|
57
|
+
* ✔ bindcontrolstoggle(only android)
|
|
58
|
+
* ✘ bindenterpictureinpicture
|
|
59
|
+
* ✘ bindleavepictureinpicture
|
|
60
|
+
* ✔ bindseekcomplete
|
|
61
|
+
* ✘ bindcastinguserselect
|
|
62
|
+
* ✘ bindcastingstatechange
|
|
63
|
+
* ✘ bindcastinginterrupt
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
import { JSX, useRef, forwardRef, createElement } from 'react'
|
|
67
|
+
import Video, { DRMType, ReactVideoSourceProperties, VideoRef, OnVideoErrorData, OnPlaybackRateChangeData, OnControlsVisibilityChange, OnBufferData, OnSeekData, OnProgressData } from 'react-native-video'
|
|
68
|
+
import { StyleSheet, View, Platform, ViewStyle } from 'react-native'
|
|
69
|
+
import {
|
|
70
|
+
splitProps,
|
|
71
|
+
useTransformStyle,
|
|
72
|
+
useLayout,
|
|
73
|
+
extendObject
|
|
74
|
+
} from './utils'
|
|
75
|
+
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
76
|
+
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
77
|
+
|
|
78
|
+
interface VideoProps {
|
|
79
|
+
src: string;
|
|
80
|
+
autoplay?: boolean;
|
|
81
|
+
loop?: boolean;
|
|
82
|
+
muted?: boolean;
|
|
83
|
+
controls?: boolean;
|
|
84
|
+
poster?: string;
|
|
85
|
+
style?: ViewStyle;
|
|
86
|
+
'initial-time'?: number;
|
|
87
|
+
'object-fit'?: null | 'contain' | 'fill' | 'cover';
|
|
88
|
+
'is-drm'?: boolean;
|
|
89
|
+
'provision-url'?: string;
|
|
90
|
+
'certificate-url'?: string;
|
|
91
|
+
'license-url'?: string;
|
|
92
|
+
'preferred-peak-bit-rate'?: number;
|
|
93
|
+
'enable-auto-rotation'?: number;
|
|
94
|
+
'enable-var'?: boolean;
|
|
95
|
+
'external-var-context'?: Record<string, any>;
|
|
96
|
+
'parent-font-size'?: number;
|
|
97
|
+
'parent-width'?: number;
|
|
98
|
+
'parent-height'?: number;
|
|
99
|
+
bindplay?: (event: Record<string, any>) => void;
|
|
100
|
+
bindpause?: (event: Record<string, any>) => void;
|
|
101
|
+
bindended?: (event: Record<string, any>) => void;
|
|
102
|
+
bindtimeupdate?: (event: Record<string, any>) => void;
|
|
103
|
+
bindfullscreenchange?: (event: Record<string, any>) => void;
|
|
104
|
+
bindwaiting?: (event: Record<string, any>) => void;
|
|
105
|
+
binderror?: (event: Record<string, any>) => void;
|
|
106
|
+
bindloadedmetadata?: (event: Record<string, any>) => void;
|
|
107
|
+
bindcontrolstoggle?: (event: Record<string, any>) => void;
|
|
108
|
+
bindseekcomplete?: (event: Record<string, any>) => void;
|
|
109
|
+
}
|
|
110
|
+
interface VideoInfoData {
|
|
111
|
+
naturalSize: {
|
|
112
|
+
width: number
|
|
113
|
+
height: number
|
|
114
|
+
}
|
|
115
|
+
duration: number
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const styles = StyleSheet.create({
|
|
119
|
+
container: {
|
|
120
|
+
width: 300,
|
|
121
|
+
height: 225
|
|
122
|
+
},
|
|
123
|
+
video: {
|
|
124
|
+
flex: 1
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProps: VideoProps, ref): JSX.Element => {
|
|
129
|
+
const { innerProps: props = {} } = splitProps(videoProps)
|
|
130
|
+
const {
|
|
131
|
+
src,
|
|
132
|
+
autoplay = false,
|
|
133
|
+
loop = false,
|
|
134
|
+
muted = false,
|
|
135
|
+
controls = true,
|
|
136
|
+
poster = '',
|
|
137
|
+
bindplay,
|
|
138
|
+
bindpause,
|
|
139
|
+
bindended,
|
|
140
|
+
bindtimeupdate,
|
|
141
|
+
bindfullscreenchange,
|
|
142
|
+
bindwaiting,
|
|
143
|
+
binderror,
|
|
144
|
+
bindloadedmetadata,
|
|
145
|
+
bindcontrolstoggle,
|
|
146
|
+
bindseekcomplete,
|
|
147
|
+
style,
|
|
148
|
+
'initial-time': initialTime = 0,
|
|
149
|
+
'object-fit': objectFit = 'contain',
|
|
150
|
+
'is-drm': isDrm = false,
|
|
151
|
+
'provision-url': provisionUrl,
|
|
152
|
+
'certificate-url': certificateUrl,
|
|
153
|
+
'license-url': licenseUrl,
|
|
154
|
+
'preferred-peak-bit-rate': preferredPeakBitRate = 0,
|
|
155
|
+
'enable-auto-rotation': enableAutoRotation = false,
|
|
156
|
+
'enable-var': enableVar,
|
|
157
|
+
'external-var-context': externalVarContext,
|
|
158
|
+
'parent-font-size': parentFontSize,
|
|
159
|
+
'parent-width': parentWidth,
|
|
160
|
+
'parent-height': parentHeight
|
|
161
|
+
} = props
|
|
162
|
+
|
|
163
|
+
const videoRef = useRef<VideoRef>(null)
|
|
164
|
+
|
|
165
|
+
const viewRef = useRef(null)
|
|
166
|
+
|
|
167
|
+
const videoInfoRef = useRef({} as VideoInfoData)
|
|
168
|
+
|
|
169
|
+
const propsRef = useRef({})
|
|
170
|
+
|
|
171
|
+
propsRef.current = props
|
|
172
|
+
|
|
173
|
+
const { normalStyle, hasSelfPercent, setWidth, setHeight } =
|
|
174
|
+
useTransformStyle(extendObject({}, styles.container, style), {
|
|
175
|
+
enableVar,
|
|
176
|
+
externalVarContext,
|
|
177
|
+
parentFontSize,
|
|
178
|
+
parentWidth,
|
|
179
|
+
parentHeight
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({
|
|
183
|
+
props,
|
|
184
|
+
hasSelfPercent,
|
|
185
|
+
setWidth,
|
|
186
|
+
setHeight,
|
|
187
|
+
nodeRef: viewRef
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
useNodesRef(props, ref, viewRef, {
|
|
191
|
+
style: normalStyle,
|
|
192
|
+
node: {
|
|
193
|
+
play,
|
|
194
|
+
pause,
|
|
195
|
+
stop,
|
|
196
|
+
seek,
|
|
197
|
+
requestFullScreen,
|
|
198
|
+
exitFullScreen
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
function handleProgress (data: OnProgressData) {
|
|
203
|
+
const { currentTime } = data
|
|
204
|
+
bindtimeupdate && bindtimeupdate(
|
|
205
|
+
getCustomEvent('timeupdate',
|
|
206
|
+
{},
|
|
207
|
+
{
|
|
208
|
+
detail: {
|
|
209
|
+
currentTime,
|
|
210
|
+
duration: videoInfoRef.current.duration
|
|
211
|
+
},
|
|
212
|
+
layoutRef
|
|
213
|
+
},
|
|
214
|
+
propsRef.current
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function handleEnd () {
|
|
220
|
+
bindended!(getCustomEvent('end', {}, { layoutRef }, propsRef.current))
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function handleWaiting ({ isBuffering }: OnBufferData) {
|
|
224
|
+
if (isBuffering) {
|
|
225
|
+
bindwaiting!(getCustomEvent('waiting', {}, { layoutRef }, propsRef.current))
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function handleSeekcomplete ({ seekTime }: OnSeekData) {
|
|
230
|
+
// 手动拖拽进度条场景,android 可以触发,ios 不可以
|
|
231
|
+
bindseekcomplete!(
|
|
232
|
+
getCustomEvent('seekcomplete',
|
|
233
|
+
{},
|
|
234
|
+
{
|
|
235
|
+
detail: {
|
|
236
|
+
position: Platform.OS === 'android' ? seekTime * 1000 : seekTime
|
|
237
|
+
},
|
|
238
|
+
layoutRef
|
|
239
|
+
},
|
|
240
|
+
propsRef.current
|
|
241
|
+
))
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function handleEnterFullScreen () {
|
|
245
|
+
bindfullscreenchange && bindfullscreenchange(
|
|
246
|
+
getCustomEvent('fullscreenchange', {}, { detail: { fullScreen: 1 }, layoutRef }, propsRef.current)
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function handleExitFullScreen () {
|
|
251
|
+
bindfullscreenchange && bindfullscreenchange(
|
|
252
|
+
getCustomEvent('fullscreenchange', {}, { detail: { fullScreen: 0 }, layoutRef }, propsRef.current)
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function handlePlaybackRateChange ({ playbackRate }: OnPlaybackRateChangeData) {
|
|
257
|
+
if (playbackRate === 0) {
|
|
258
|
+
bindpause && bindpause(getCustomEvent('pause', {}, { layoutRef }, propsRef.current))
|
|
259
|
+
} else {
|
|
260
|
+
bindplay && bindplay(getCustomEvent('play', {}, { layoutRef }, propsRef.current))
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function handleAndroidControlsVisibilityChange ({ isVisible }: OnControlsVisibilityChange) {
|
|
265
|
+
bindcontrolstoggle!(
|
|
266
|
+
getCustomEvent('progress',
|
|
267
|
+
{},
|
|
268
|
+
{
|
|
269
|
+
detail: {
|
|
270
|
+
show: isVisible
|
|
271
|
+
},
|
|
272
|
+
layoutRef
|
|
273
|
+
},
|
|
274
|
+
propsRef.current
|
|
275
|
+
))
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function handleVideoLoad (data: VideoInfoData) {
|
|
279
|
+
const { naturalSize, duration } = data
|
|
280
|
+
if (initialTime) {
|
|
281
|
+
videoRef.current && videoRef.current.seek(initialTime)
|
|
282
|
+
}
|
|
283
|
+
videoInfoRef.current = data
|
|
284
|
+
bindloadedmetadata && bindloadedmetadata(getCustomEvent('loadedmetadata',
|
|
285
|
+
{},
|
|
286
|
+
{
|
|
287
|
+
detail: {
|
|
288
|
+
width: naturalSize.width,
|
|
289
|
+
height: naturalSize.height,
|
|
290
|
+
duration
|
|
291
|
+
},
|
|
292
|
+
layoutRef
|
|
293
|
+
},
|
|
294
|
+
propsRef.current
|
|
295
|
+
))
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function handleError ({ error }: OnVideoErrorData) {
|
|
299
|
+
binderror && binderror(getCustomEvent('play', {}, { detail: { errMsg: error.localizedFailureReason }, layoutRef }, propsRef.current))
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function play () {
|
|
303
|
+
videoRef.current && videoRef.current.resume()
|
|
304
|
+
}
|
|
305
|
+
function pause () {
|
|
306
|
+
videoRef.current && videoRef.current.pause()
|
|
307
|
+
}
|
|
308
|
+
function seek (position: number) {
|
|
309
|
+
videoRef.current && videoRef.current.seek(position)
|
|
310
|
+
}
|
|
311
|
+
function stop () {
|
|
312
|
+
videoRef.current && videoRef.current.pause()
|
|
313
|
+
seek(0)
|
|
314
|
+
}
|
|
315
|
+
function exitFullScreen () {
|
|
316
|
+
videoRef.current && videoRef.current.setFullScreen(false)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function requestFullScreen () {
|
|
320
|
+
videoRef.current && videoRef.current.setFullScreen(true)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const source: ReactVideoSourceProperties = {
|
|
324
|
+
uri: src
|
|
325
|
+
}
|
|
326
|
+
if (isDrm) {
|
|
327
|
+
source.drm = {
|
|
328
|
+
type: DRMType.FAIRPLAY,
|
|
329
|
+
certificateUrl: Platform.OS === 'android' ? provisionUrl : certificateUrl,
|
|
330
|
+
licenseServer: licenseUrl
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const innerProps = useInnerProps(
|
|
335
|
+
props,
|
|
336
|
+
extendObject(
|
|
337
|
+
{
|
|
338
|
+
style: styles.video,
|
|
339
|
+
ref: videoRef,
|
|
340
|
+
source,
|
|
341
|
+
paused: !autoplay,
|
|
342
|
+
repeat: loop,
|
|
343
|
+
muted,
|
|
344
|
+
controls,
|
|
345
|
+
maxBitRate: preferredPeakBitRate,
|
|
346
|
+
fullscreenAutorotate: enableAutoRotation,
|
|
347
|
+
resizeMode: objectFit === 'fill' ? 'stretch' : objectFit,
|
|
348
|
+
poster: controls ? poster : '',
|
|
349
|
+
onProgress: bindtimeupdate && handleProgress,
|
|
350
|
+
onEnd: bindended && handleEnd,
|
|
351
|
+
onError: binderror && handleError,
|
|
352
|
+
onBuffer: bindwaiting && handleWaiting,
|
|
353
|
+
onSeek: bindseekcomplete && handleSeekcomplete,
|
|
354
|
+
onPlaybackRateChange:
|
|
355
|
+
(bindpause || bindplay) && handlePlaybackRateChange,
|
|
356
|
+
onFullscreenPlayerDidPresent:
|
|
357
|
+
bindfullscreenchange && handleEnterFullScreen,
|
|
358
|
+
onFullscreenPlayerWillDismiss:
|
|
359
|
+
bindfullscreenchange && handleExitFullScreen,
|
|
360
|
+
onControlsVisibilityChange:
|
|
361
|
+
bindcontrolstoggle && handleAndroidControlsVisibilityChange,
|
|
362
|
+
onLoad: handleVideoLoad
|
|
363
|
+
},
|
|
364
|
+
layoutProps
|
|
365
|
+
),
|
|
366
|
+
[
|
|
367
|
+
'src',
|
|
368
|
+
'autoplay',
|
|
369
|
+
'loop',
|
|
370
|
+
'bindplay',
|
|
371
|
+
'bindpause',
|
|
372
|
+
'bindended',
|
|
373
|
+
'bindtimeupdate',
|
|
374
|
+
'bindfullscreenchange',
|
|
375
|
+
'bindwaiting',
|
|
376
|
+
'binderror',
|
|
377
|
+
'bindloadedmetadata',
|
|
378
|
+
'bindcontrolstoggle',
|
|
379
|
+
'bindseekcomplete'
|
|
380
|
+
],
|
|
381
|
+
{ layoutRef }
|
|
382
|
+
)
|
|
383
|
+
return createElement(View, { style: extendObject({}, normalStyle, layoutStyle), ref: viewRef },
|
|
384
|
+
createElement(Video, innerProps)
|
|
385
|
+
)
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
export default MpxVideo
|