@mpxjs/webpack-plugin 2.8.25-alpha.21 → 2.8.25-alpha.22
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/runtime/components/react/dist/KeyboardAvoidingView.jsx +89 -0
- package/lib/runtime/components/react/dist/context.js +14 -0
- package/lib/runtime/components/react/dist/event.config.js +27 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +262 -0
- package/lib/runtime/components/react/dist/mpx-button.jsx +271 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +341 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +236 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +90 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +131 -0
- package/lib/runtime/components/react/dist/mpx-form.jsx +68 -0
- 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 +292 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +292 -0
- package/lib/runtime/components/react/dist/mpx-label.jsx +52 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +32 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +468 -0
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +33 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +74 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +141 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +147 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +99 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.js +6099 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +81 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +242 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.js +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +35 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +193 -0
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +125 -0
- 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-radio-group.jsx +86 -0
- package/lib/runtime/components/react/dist/mpx-radio.jsx +140 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +62 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +17 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +372 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +59 -0
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +671 -0
- package/lib/runtime/components/react/dist/mpx-switch.jsx +97 -0
- package/lib/runtime/components/react/dist/mpx-text.jsx +41 -0
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +40 -0
- package/lib/runtime/components/react/dist/mpx-video.jsx +248 -0
- package/lib/runtime/components/react/dist/mpx-view.jsx +611 -0
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +289 -0
- package/lib/runtime/components/react/dist/parser.js +218 -0
- package/lib/runtime/components/react/dist/pickerFaces.js +76 -0
- package/lib/runtime/components/react/dist/pickerVIewContext.js +14 -0
- package/lib/runtime/components/react/dist/pickerViewIndicator.jsx +23 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.js +346 -0
- package/lib/runtime/components/react/dist/useNodesRef.js +16 -0
- package/lib/runtime/components/react/dist/utils.jsx +599 -0
- package/package.json +6 -3
- package/LICENSE +0 -433
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✔ checked
|
|
3
|
+
* ✔ type
|
|
4
|
+
* ✔ disabled
|
|
5
|
+
* ✔ color
|
|
6
|
+
*/
|
|
7
|
+
import { Switch } from 'react-native';
|
|
8
|
+
import { useRef, useEffect, forwardRef, useState, useContext, createElement } from 'react';
|
|
9
|
+
import { warn } from '@mpxjs/utils';
|
|
10
|
+
import useNodesRef from './useNodesRef'; // 引入辅助函数
|
|
11
|
+
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
12
|
+
import CheckBox from './mpx-checkbox';
|
|
13
|
+
import { FormContext } from './context';
|
|
14
|
+
import { useTransformStyle, useLayout, extendObject } from './utils';
|
|
15
|
+
const _Switch = forwardRef((props, ref) => {
|
|
16
|
+
const { style = {}, checked = false, type = 'switch', disabled = false, color = '#04BE02', 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, bindchange, catchchange } = props;
|
|
17
|
+
const [isChecked, setIsChecked] = useState(checked);
|
|
18
|
+
const changeHandler = bindchange || catchchange;
|
|
19
|
+
let formValuesMap;
|
|
20
|
+
const formContext = useContext(FormContext);
|
|
21
|
+
if (formContext) {
|
|
22
|
+
formValuesMap = formContext.formValuesMap;
|
|
23
|
+
}
|
|
24
|
+
const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, {
|
|
25
|
+
enableVar,
|
|
26
|
+
externalVarContext,
|
|
27
|
+
parentFontSize,
|
|
28
|
+
parentWidth,
|
|
29
|
+
parentHeight
|
|
30
|
+
});
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setIsChecked(checked);
|
|
33
|
+
}, [checked]);
|
|
34
|
+
const nodeRef = useRef(null);
|
|
35
|
+
useNodesRef(props, ref, nodeRef, {
|
|
36
|
+
style: normalStyle
|
|
37
|
+
});
|
|
38
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
39
|
+
const onChange = (evt, { checked } = {}) => {
|
|
40
|
+
if (type === 'switch') {
|
|
41
|
+
setIsChecked(evt);
|
|
42
|
+
changeHandler && changeHandler(getCustomEvent('change', {}, { layoutRef, detail: { value: evt } }, props));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
setIsChecked(checked);
|
|
46
|
+
changeHandler && changeHandler(getCustomEvent('change', evt, { layoutRef, detail: { value: checked } }, props));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const resetValue = () => {
|
|
50
|
+
setIsChecked(false);
|
|
51
|
+
};
|
|
52
|
+
const getValue = () => {
|
|
53
|
+
return isChecked;
|
|
54
|
+
};
|
|
55
|
+
if (formValuesMap) {
|
|
56
|
+
if (!props.name) {
|
|
57
|
+
warn('If a form component is used, the name attribute is required.');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
formValuesMap.set(props.name, { getValue, resetValue });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
return () => {
|
|
65
|
+
if (formValuesMap && props.name) {
|
|
66
|
+
formValuesMap.delete(props.name);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
const innerProps = useInnerProps(props, extendObject({
|
|
71
|
+
ref: nodeRef,
|
|
72
|
+
style: extendObject({}, normalStyle, layoutStyle)
|
|
73
|
+
}, layoutProps, !disabled ? { [type === 'switch' ? 'onValueChange' : '_onChange']: onChange } : {}), [
|
|
74
|
+
'checked',
|
|
75
|
+
'disabled',
|
|
76
|
+
'type',
|
|
77
|
+
'color'
|
|
78
|
+
], {
|
|
79
|
+
layoutRef
|
|
80
|
+
});
|
|
81
|
+
if (type === 'checkbox') {
|
|
82
|
+
return createElement(CheckBox, extendObject({}, innerProps, {
|
|
83
|
+
color: color,
|
|
84
|
+
style: normalStyle,
|
|
85
|
+
checked: isChecked
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
return createElement(Switch, extendObject({}, innerProps, {
|
|
89
|
+
style: normalStyle,
|
|
90
|
+
value: isChecked,
|
|
91
|
+
trackColor: { false: '#FFF', true: color },
|
|
92
|
+
thumbColor: isChecked ? '#FFF' : '#f4f3f4',
|
|
93
|
+
ios_backgroundColor: '#FFF'
|
|
94
|
+
}));
|
|
95
|
+
});
|
|
96
|
+
_Switch.displayName = 'MpxSwitch';
|
|
97
|
+
export default _Switch;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✔ selectable
|
|
3
|
+
* ✘ space
|
|
4
|
+
* ✘ decode
|
|
5
|
+
*/
|
|
6
|
+
import { Text } from 'react-native';
|
|
7
|
+
import { useRef, forwardRef, createElement } from 'react';
|
|
8
|
+
import useInnerProps from './getInnerListeners';
|
|
9
|
+
import useNodesRef from './useNodesRef'; // 引入辅助函数
|
|
10
|
+
import { useTransformStyle, wrapChildren } from './utils';
|
|
11
|
+
const _Text = forwardRef((props, ref) => {
|
|
12
|
+
const { style = {}, allowFontScaling = false, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
13
|
+
const layoutRef = useRef({});
|
|
14
|
+
const { normalStyle, hasVarDec, varContextRef } = useTransformStyle(style, {
|
|
15
|
+
enableVar,
|
|
16
|
+
externalVarContext,
|
|
17
|
+
parentFontSize,
|
|
18
|
+
parentWidth,
|
|
19
|
+
parentHeight
|
|
20
|
+
});
|
|
21
|
+
const nodeRef = useRef(null);
|
|
22
|
+
useNodesRef(props, ref, nodeRef, {
|
|
23
|
+
style: normalStyle
|
|
24
|
+
});
|
|
25
|
+
const innerProps = useInnerProps(props, {
|
|
26
|
+
ref: nodeRef,
|
|
27
|
+
style: normalStyle,
|
|
28
|
+
selectable: !!selectable || !!userSelect,
|
|
29
|
+
allowFontScaling
|
|
30
|
+
}, [
|
|
31
|
+
'user-select'
|
|
32
|
+
], {
|
|
33
|
+
layoutRef
|
|
34
|
+
});
|
|
35
|
+
return createElement(Text, innerProps, wrapChildren(props, {
|
|
36
|
+
hasVarDec,
|
|
37
|
+
varContext: varContextRef.current
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
_Text.displayName = 'MpxText';
|
|
41
|
+
export default _Text;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compared with Input:
|
|
3
|
+
* Subtraction:
|
|
4
|
+
* type, password, confirm-hold
|
|
5
|
+
* Addition:
|
|
6
|
+
* - confirm-type: Not support `return`
|
|
7
|
+
* ✔ auto-height
|
|
8
|
+
* ✘ fixed
|
|
9
|
+
* ✘ show-confirm-bar
|
|
10
|
+
* ✔ bindlinechange: No `heightRpx` info.
|
|
11
|
+
*/
|
|
12
|
+
import { forwardRef, createElement } from 'react';
|
|
13
|
+
import { Keyboard } from 'react-native';
|
|
14
|
+
import Input from './mpx-input';
|
|
15
|
+
import { omit, extendObject } from './utils';
|
|
16
|
+
const DEFAULT_TEXTAREA_WIDTH = 300;
|
|
17
|
+
const DEFAULT_TEXTAREA_HEIGHT = 150;
|
|
18
|
+
const Textarea = forwardRef((props, ref) => {
|
|
19
|
+
const { style = {} } = props;
|
|
20
|
+
const restProps = omit(props, [
|
|
21
|
+
'ref',
|
|
22
|
+
'type',
|
|
23
|
+
'style',
|
|
24
|
+
'password',
|
|
25
|
+
'multiline',
|
|
26
|
+
'confirm-hold'
|
|
27
|
+
]);
|
|
28
|
+
return createElement(Input, extendObject(restProps, {
|
|
29
|
+
ref: ref,
|
|
30
|
+
multiline: true,
|
|
31
|
+
confirmType: 'next',
|
|
32
|
+
bindblur: () => Keyboard.dismiss(),
|
|
33
|
+
style: extendObject({
|
|
34
|
+
width: DEFAULT_TEXTAREA_WIDTH,
|
|
35
|
+
height: DEFAULT_TEXTAREA_HEIGHT
|
|
36
|
+
}, style)
|
|
37
|
+
}));
|
|
38
|
+
});
|
|
39
|
+
Textarea.displayName = 'MpxTextarea';
|
|
40
|
+
export default Textarea;
|
|
@@ -0,0 +1,248 @@
|
|
|
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
|
+
import { useRef, forwardRef, createElement } from 'react';
|
|
66
|
+
import Video, { DRMType } from 'react-native-video';
|
|
67
|
+
import { StyleSheet, View, Platform } from 'react-native';
|
|
68
|
+
import { splitProps, useTransformStyle, useLayout, extendObject } from './utils';
|
|
69
|
+
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
70
|
+
import useNodesRef from './useNodesRef';
|
|
71
|
+
const styles = StyleSheet.create({
|
|
72
|
+
container: {
|
|
73
|
+
width: 300,
|
|
74
|
+
height: 225
|
|
75
|
+
},
|
|
76
|
+
video: {
|
|
77
|
+
flex: 1
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const MpxVideo = forwardRef((videoProps, ref) => {
|
|
81
|
+
const { innerProps: props = {} } = splitProps(videoProps);
|
|
82
|
+
const { src, autoplay = false, loop = false, muted = false, controls = true, poster = '', bindplay, bindpause, bindended, bindtimeupdate, bindfullscreenchange, bindwaiting, binderror, bindloadedmetadata, bindcontrolstoggle, bindseekcomplete, style, 'initial-time': initialTime = 0, 'object-fit': objectFit = 'contain', 'is-drm': isDrm = false, 'provision-url': provisionUrl, 'certificate-url': certificateUrl, 'license-url': licenseUrl, 'preferred-peak-bit-rate': preferredPeakBitRate = 0, 'enable-auto-rotation': enableAutoRotation = false, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
83
|
+
const videoRef = useRef(null);
|
|
84
|
+
const viewRef = useRef(null);
|
|
85
|
+
const videoInfoRef = useRef({});
|
|
86
|
+
const propsRef = useRef({});
|
|
87
|
+
propsRef.current = props;
|
|
88
|
+
const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(extendObject({}, styles.container, style), {
|
|
89
|
+
enableVar,
|
|
90
|
+
externalVarContext,
|
|
91
|
+
parentFontSize,
|
|
92
|
+
parentWidth,
|
|
93
|
+
parentHeight
|
|
94
|
+
});
|
|
95
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({
|
|
96
|
+
props,
|
|
97
|
+
hasSelfPercent,
|
|
98
|
+
setWidth,
|
|
99
|
+
setHeight,
|
|
100
|
+
nodeRef: viewRef
|
|
101
|
+
});
|
|
102
|
+
useNodesRef(props, ref, viewRef, {
|
|
103
|
+
style: normalStyle,
|
|
104
|
+
node: {
|
|
105
|
+
play,
|
|
106
|
+
pause,
|
|
107
|
+
stop,
|
|
108
|
+
seek,
|
|
109
|
+
requestFullScreen,
|
|
110
|
+
exitFullScreen
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
function handleProgress(data) {
|
|
114
|
+
const { currentTime } = data;
|
|
115
|
+
bindtimeupdate && bindtimeupdate(getCustomEvent('timeupdate', {}, {
|
|
116
|
+
detail: {
|
|
117
|
+
currentTime,
|
|
118
|
+
duration: videoInfoRef.current.duration
|
|
119
|
+
},
|
|
120
|
+
layoutRef
|
|
121
|
+
}, propsRef.current));
|
|
122
|
+
}
|
|
123
|
+
function handleEnd() {
|
|
124
|
+
bindended(getCustomEvent('end', {}, { layoutRef }, propsRef.current));
|
|
125
|
+
}
|
|
126
|
+
function handleWaiting({ isBuffering }) {
|
|
127
|
+
if (isBuffering) {
|
|
128
|
+
bindwaiting(getCustomEvent('waiting', {}, { layoutRef }, propsRef.current));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function handleSeekcomplete({ seekTime }) {
|
|
132
|
+
// 手动拖拽进度条场景,android 可以触发,ios 不可以
|
|
133
|
+
bindseekcomplete(getCustomEvent('seekcomplete', {}, {
|
|
134
|
+
detail: {
|
|
135
|
+
position: Platform.OS === 'android' ? seekTime * 1000 : seekTime
|
|
136
|
+
},
|
|
137
|
+
layoutRef
|
|
138
|
+
}, propsRef.current));
|
|
139
|
+
}
|
|
140
|
+
function handleEnterFullScreen() {
|
|
141
|
+
bindfullscreenchange && bindfullscreenchange(getCustomEvent('fullscreenchange', {}, { detail: { fullScreen: 1 }, layoutRef }, propsRef.current));
|
|
142
|
+
}
|
|
143
|
+
function handleExitFullScreen() {
|
|
144
|
+
bindfullscreenchange && bindfullscreenchange(getCustomEvent('fullscreenchange', {}, { detail: { fullScreen: 0 }, layoutRef }, propsRef.current));
|
|
145
|
+
}
|
|
146
|
+
function handlePlaybackRateChange({ playbackRate }) {
|
|
147
|
+
if (playbackRate === 0) {
|
|
148
|
+
bindpause && bindpause(getCustomEvent('pause', {}, { layoutRef }, propsRef.current));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
bindplay && bindplay(getCustomEvent('play', {}, { layoutRef }, propsRef.current));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function handleAndroidControlsVisibilityChange({ isVisible }) {
|
|
155
|
+
bindcontrolstoggle(getCustomEvent('progress', {}, {
|
|
156
|
+
detail: {
|
|
157
|
+
show: isVisible
|
|
158
|
+
},
|
|
159
|
+
layoutRef
|
|
160
|
+
}, propsRef.current));
|
|
161
|
+
}
|
|
162
|
+
function handleVideoLoad(data) {
|
|
163
|
+
const { naturalSize, duration } = data;
|
|
164
|
+
if (initialTime) {
|
|
165
|
+
videoRef.current && videoRef.current.seek(initialTime);
|
|
166
|
+
}
|
|
167
|
+
videoInfoRef.current = data;
|
|
168
|
+
bindloadedmetadata && bindloadedmetadata(getCustomEvent('loadedmetadata', {}, {
|
|
169
|
+
detail: {
|
|
170
|
+
width: naturalSize.width,
|
|
171
|
+
height: naturalSize.height,
|
|
172
|
+
duration
|
|
173
|
+
},
|
|
174
|
+
layoutRef
|
|
175
|
+
}, propsRef.current));
|
|
176
|
+
}
|
|
177
|
+
function handleError({ error }) {
|
|
178
|
+
binderror && binderror(getCustomEvent('play', {}, { detail: { errMsg: error.localizedFailureReason }, layoutRef }, propsRef.current));
|
|
179
|
+
}
|
|
180
|
+
function play() {
|
|
181
|
+
videoRef.current && videoRef.current.resume();
|
|
182
|
+
}
|
|
183
|
+
function pause() {
|
|
184
|
+
videoRef.current && videoRef.current.pause();
|
|
185
|
+
}
|
|
186
|
+
function seek(position) {
|
|
187
|
+
videoRef.current && videoRef.current.seek(position);
|
|
188
|
+
}
|
|
189
|
+
function stop() {
|
|
190
|
+
videoRef.current && videoRef.current.pause();
|
|
191
|
+
seek(0);
|
|
192
|
+
}
|
|
193
|
+
function exitFullScreen() {
|
|
194
|
+
videoRef.current && videoRef.current.setFullScreen(false);
|
|
195
|
+
}
|
|
196
|
+
function requestFullScreen() {
|
|
197
|
+
videoRef.current && videoRef.current.setFullScreen(true);
|
|
198
|
+
}
|
|
199
|
+
const source = {
|
|
200
|
+
uri: src
|
|
201
|
+
};
|
|
202
|
+
if (isDrm) {
|
|
203
|
+
source.drm = {
|
|
204
|
+
type: DRMType.FAIRPLAY,
|
|
205
|
+
certificateUrl: Platform.OS === 'android' ? provisionUrl : certificateUrl,
|
|
206
|
+
licenseServer: licenseUrl
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const innerProps = useInnerProps(props, extendObject({
|
|
210
|
+
style: styles.video,
|
|
211
|
+
ref: videoRef,
|
|
212
|
+
source,
|
|
213
|
+
paused: !autoplay,
|
|
214
|
+
repeat: loop,
|
|
215
|
+
muted,
|
|
216
|
+
controls,
|
|
217
|
+
maxBitRate: preferredPeakBitRate,
|
|
218
|
+
fullscreenAutorotate: enableAutoRotation,
|
|
219
|
+
resizeMode: objectFit === 'fill' ? 'stretch' : objectFit,
|
|
220
|
+
poster: controls ? poster : '',
|
|
221
|
+
onProgress: bindtimeupdate && handleProgress,
|
|
222
|
+
onEnd: bindended && handleEnd,
|
|
223
|
+
onError: binderror && handleError,
|
|
224
|
+
onBuffer: bindwaiting && handleWaiting,
|
|
225
|
+
onSeek: bindseekcomplete && handleSeekcomplete,
|
|
226
|
+
onPlaybackRateChange: (bindpause || bindplay) && handlePlaybackRateChange,
|
|
227
|
+
onFullscreenPlayerDidPresent: bindfullscreenchange && handleEnterFullScreen,
|
|
228
|
+
onFullscreenPlayerWillDismiss: bindfullscreenchange && handleExitFullScreen,
|
|
229
|
+
onControlsVisibilityChange: bindcontrolstoggle && handleAndroidControlsVisibilityChange,
|
|
230
|
+
onLoad: handleVideoLoad
|
|
231
|
+
}, layoutProps), [
|
|
232
|
+
'src',
|
|
233
|
+
'autoplay',
|
|
234
|
+
'loop',
|
|
235
|
+
'bindplay',
|
|
236
|
+
'bindpause',
|
|
237
|
+
'bindended',
|
|
238
|
+
'bindtimeupdate',
|
|
239
|
+
'bindfullscreenchange',
|
|
240
|
+
'bindwaiting',
|
|
241
|
+
'binderror',
|
|
242
|
+
'bindloadedmetadata',
|
|
243
|
+
'bindcontrolstoggle',
|
|
244
|
+
'bindseekcomplete'
|
|
245
|
+
], { layoutRef });
|
|
246
|
+
return createElement(View, { style: extendObject({}, normalStyle, layoutStyle), ref: viewRef }, createElement(Video, innerProps));
|
|
247
|
+
});
|
|
248
|
+
export default MpxVideo;
|