|
@@ -162,6 +162,25 @@ export default defineComponent({
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ let videoErrorTimer = null as any;
|
|
|
+ let videoErrorCount = 0;
|
|
|
+ const handleErrorVideo = () => {
|
|
|
+ if (videoErrorCount > 5) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ clearTimeout(videoErrorTimer)
|
|
|
+ nextTick(() => {
|
|
|
+ videoErrorTimer = setTimeout(() => {
|
|
|
+ data.videoContianerRef.src = props.item?.content
|
|
|
+ emit('play')
|
|
|
+ data.videoContianerRef.load()
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
+ handleErrorVideo();
|
|
|
+ }, 1000)
|
|
|
+ })
|
|
|
+ videoErrorCount++;
|
|
|
+ }
|
|
|
+
|
|
|
return () => (
|
|
|
<div class={styles.videoWrap}>
|
|
|
<video
|
|
@@ -174,14 +193,19 @@ export default defineComponent({
|
|
|
onLoadedmetadata={() => {
|
|
|
data.videoState = 'pause'
|
|
|
changePlayBtn('play');
|
|
|
- handlePlayVideo();
|
|
|
+ nextTick(() => {
|
|
|
+ data.videoContianerRef.currentTime = 0;
|
|
|
+ nextTick(handlePlayVideo)
|
|
|
+ })
|
|
|
}}
|
|
|
onPlay={() => {
|
|
|
+ videoErrorCount = 0;
|
|
|
console.log('开始播放')
|
|
|
data.videoState = 'play'
|
|
|
changePlayBtn('pause')
|
|
|
emit('close')
|
|
|
emit('play')
|
|
|
+ clearTimeout(videoErrorTimer)
|
|
|
}}
|
|
|
onPause={() => {
|
|
|
console.log('暂停播放')
|
|
@@ -195,6 +219,7 @@ export default defineComponent({
|
|
|
changePlayBtn('play')
|
|
|
emit('ended')
|
|
|
}}
|
|
|
+ onError={handleErrorVideo}
|
|
|
></video>
|
|
|
</div>
|
|
|
)
|