From 27eff078ea9424d85b71858f1a29529230e67f12 Mon Sep 17 00:00:00 2001 From: lareinayanyu Date: Fri, 10 Jan 2025 15:05:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/wx/component-config/video.js | 20 +++++++++++++ .../runtime/components/react/mpx-video.tsx | 29 ++----------------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/packages/webpack-plugin/lib/platform/template/wx/component-config/video.js b/packages/webpack-plugin/lib/platform/template/wx/component-config/video.js index 18b5bb8ee9..bcd1223bc0 100644 --- a/packages/webpack-plugin/lib/platform/template/wx/component-config/video.js +++ b/packages/webpack-plugin/lib/platform/template/wx/component-config/video.js @@ -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 }) { @@ -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: [ @@ -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 } ] } diff --git a/packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx b/packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx index 132139e26a..ae4b9ee25c 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx @@ -52,7 +52,7 @@ * ✔ bindfullscreenchange * ✔ bindwaiting * ✔ binderror - * ✔ bindprogress + * ✘ bindprogress * ✔ bindloadedmetadata * ✔ bindcontrolstoggle(only android) * ✘ bindenterpictureinpicture @@ -103,7 +103,6 @@ interface VideoProps { bindfullscreenchange?: (event: Record) => void; bindwaiting?: (event: Record) => void; binderror?: (event: Record) => void; - bindprogress?: (event: Record) => void; bindloadedmetadata?: (event: Record) => void; bindcontrolstoggle?: (event: Record) => void; bindseekcomplete?: (event: Record) => void; @@ -142,7 +141,6 @@ const MpxVideo = forwardRef, VideoProps>((videoProp bindfullscreenchange, bindwaiting, binderror, - bindprogress, bindloadedmetadata, bindcontrolstoggle, bindseekcomplete, @@ -218,27 +216,6 @@ const MpxVideo = forwardRef, 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 () { @@ -252,6 +229,7 @@ const MpxVideo = forwardRef, VideoProps>((videoProp } function handleSeekcomplete ({ seekTime }: OnSeekData) { + // 手动拖拽进度条场景,android 可以触发,ios 不可以 bindseekcomplete!( getCustomEvent('seekcomplete', {}, @@ -371,7 +349,7 @@ const MpxVideo = forwardRef, 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, @@ -399,7 +377,6 @@ const MpxVideo = forwardRef, VideoProps>((videoProp 'bindfullscreenchange', 'bindwaiting', 'binderror', - 'bindprogress', 'bindloadedmetadata', 'bindcontrolstoggle', 'bindseekcomplete'