Skip to content

Commit

Permalink
feat: 补充属性事件校验
Browse files Browse the repository at this point in the history
  • Loading branch information
lareinayanyu committed Jan 10, 2025
1 parent 3e9c778 commit 27eff07
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module.exports = function ({ print }) {
const aliEventLogError = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
const qaEventLogError = print({ platform: 'qa', tag: TAG_NAME, isError: false, type: 'event' })
const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
const iosEventLogError = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
const androidEventLogError = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
return {
test: TAG_NAME,
web (tag, { el }) {
Expand Down Expand Up @@ -55,6 +59,14 @@ module.exports = function ({ print }) {
{
test: /^(duration|danmu-list|danmu-btn|enable-danmu|muted|initial-time|page-gesture|direction|show-progress|show-center-play-btn|enable-progress-gesture|show-mute-btn|enable-play-gesture|auto-pause-if-navigate|auto-pause-if-open-native|vslide-gesture|vslide-gesture-in-fullscreen|ad-unit-id|poster-for-crawler|show-casting-button|picture-in-picture-mode|picture-in-picture-show-progress|enable-auto-rotation|show-screen-lock-button|show-snapshot-button)$/,
qa: qaPropLog
},
{
test: /^(duration|enable-danmu|danmu-btn|page-gesture|direction|show-progress|show-fullscreen-btn|show-center-play-btn|enable-progress-gesture|show-mute-btn|title|play-btn-position|enable-play-gesture|auto-pause-if-navigate|auto-pause-if-open-native|vslide-gesture|vslide-gesture-in-fullscreen|show-bottom-progress|ad-unit-id|poster-for-crawler|show-casting-button|picture-in-picture-mode|picture-in-picture-show-progress| picture-in-picture-init-position|show-snapshot-button|show-screen-lock-button|show-background-playback-button|background-poster|referrer-policy|is-live)$/,
ios: iosPropLog
},
{
test: /^(duration|enable-danmu|danmu-btn|page-gesture|direction|show-progress|show-fullscreen-btn|show-center-play-btn|enable-progress-gesture|show-mute-btn|title|play-btn-position|enable-play-gesture|auto-pause-if-navigate|auto-pause-if-open-native|vslide-gesture|vslide-gesture-in-fullscreen|show-bottom-progress|ad-unit-id|poster-for-crawler|show-casting-button|picture-in-picture-mode|picture-in-picture-show-progress| picture-in-picture-init-position|enable-auto-rotation|show-snapshot-button|show-screen-lock-button|show-background-playback-button|background-poster|referrer-policy|is-live)$/,
android: androidPropLog
}
],
event: [
Expand Down Expand Up @@ -89,6 +101,14 @@ module.exports = function ({ print }) {
{
test: /^(progress|enterpictureinpicture|leavepictureinpicture|controlstoggle|loadedmetadata|seekcomplete)$/,
qa: qaEventLogError
},
{
test: /^(progress|controlstoggle|enterpictureinpicture|leavepictureinpicture|castinguserselect|castingstatechange|castinginterrupt)$/,
ios: iosEventLogError
},
{
test: /^(progress|enterpictureinpicture|leavepictureinpicture|castinguserselect|castingstatechange|castinginterrupt)$/,
android: androidEventLogError
}
]
}
Expand Down
29 changes: 3 additions & 26 deletions packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* ✔ bindfullscreenchange
* ✔ bindwaiting
* ✔ binderror
* bindprogress
* bindprogress
* ✔ bindloadedmetadata
* ✔ bindcontrolstoggle(only android)
* ✘ bindenterpictureinpicture
Expand Down Expand Up @@ -103,7 +103,6 @@ interface VideoProps {
bindfullscreenchange?: (event: Record<string, any>) => void;
bindwaiting?: (event: Record<string, any>) => void;
binderror?: (event: Record<string, any>) => void;
bindprogress?: (event: Record<string, any>) => void;
bindloadedmetadata?: (event: Record<string, any>) => void;
bindcontrolstoggle?: (event: Record<string, any>) => void;
bindseekcomplete?: (event: Record<string, any>) => void;
Expand Down Expand Up @@ -142,7 +141,6 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
bindfullscreenchange,
bindwaiting,
binderror,
bindprogress,
bindloadedmetadata,
bindcontrolstoggle,
bindseekcomplete,
Expand Down Expand Up @@ -218,27 +216,6 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
propsRef.current
)
)
// 计算缓冲的百分比
const duration = videoInfoRef.current.duration || 0
let currentBufferedPercentage = (playableDuration / duration) * 100
// playableDuration 比 duration 更精确,会精确到小数,可能会出现大于 100 的情况
if (currentBufferedPercentage > 100) {
currentBufferedPercentage = 100
}
if (currentBufferedPercentage !== bufferedPercentage.current) {
bufferedPercentage.current = currentBufferedPercentage
bindprogress && bindprogress(
getCustomEvent('progress',
{},
{
detail: {
buffered: currentBufferedPercentage || 0
},
layoutRef
},
propsRef.current
))
}
}

function handleEnd () {
Expand All @@ -252,6 +229,7 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
}

function handleSeekcomplete ({ seekTime }: OnSeekData) {
// 手动拖拽进度条场景,android 可以触发,ios 不可以
bindseekcomplete!(
getCustomEvent('seekcomplete',
{},
Expand Down Expand Up @@ -371,7 +349,7 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
fullscreenAutorotate: enableAutoRotation,
resizeMode: objectFit === 'fill' ? 'stretch' : objectFit,
poster: controls ? poster : '',
onProgress: (bindtimeupdate || bindprogress) && handleProgress,
onProgress: bindtimeupdate && handleProgress,
onEnd: bindended && handleEnd,
onError: binderror && handleError,
onBuffer: bindwaiting && handleWaiting,
Expand Down Expand Up @@ -399,7 +377,6 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
'bindfullscreenchange',
'bindwaiting',
'binderror',
'bindprogress',
'bindloadedmetadata',
'bindcontrolstoggle',
'bindseekcomplete'
Expand Down

0 comments on commit 27eff07

Please sign in to comment.