|
@@ -7,6 +7,7 @@ import iconLoop from '../../image/icon-loop.svg'
|
|
|
import iconLoopActive from '../../image/icon-loop-active.svg'
|
|
|
import iconplay from '../../image/icon-play.svg'
|
|
|
import iconpause from '../../image/icon-pause.svg'
|
|
|
+import { iconVideoBg } from '../../image/icons.json'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'video-play',
|
|
@@ -151,22 +152,22 @@ export default defineComponent({
|
|
|
clearTimeout(videoTimer)
|
|
|
nextTick(() => {
|
|
|
data.videoContianerRef.play().catch((err) => {
|
|
|
- console.log("🚀 ~ err:", err)
|
|
|
+ console.log('🚀 ~ err:', err)
|
|
|
videoTimer = setTimeout(() => {
|
|
|
if (err?.message?.includes('play()')) {
|
|
|
emit('play')
|
|
|
}
|
|
|
- handlePlayVideo();
|
|
|
+ handlePlayVideo()
|
|
|
}, 1000)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- let videoErrorTimer = null as any;
|
|
|
- let videoErrorCount = 0;
|
|
|
+ let videoErrorTimer = null as any
|
|
|
+ let videoErrorCount = 0
|
|
|
const handleErrorVideo = () => {
|
|
|
if (videoErrorCount > 5) {
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
clearTimeout(videoErrorTimer)
|
|
|
nextTick(() => {
|
|
@@ -175,10 +176,10 @@ export default defineComponent({
|
|
|
emit('play')
|
|
|
data.videoContianerRef.load()
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
- handleErrorVideo();
|
|
|
+ handleErrorVideo()
|
|
|
}, 1000)
|
|
|
})
|
|
|
- videoErrorCount++;
|
|
|
+ videoErrorCount++
|
|
|
}
|
|
|
|
|
|
return () => (
|
|
@@ -187,19 +188,20 @@ export default defineComponent({
|
|
|
ref={(el) => (data.videoContianerRef = el as unknown as HTMLAudioElement)}
|
|
|
class={styles.itemDiv}
|
|
|
src={props.item?.content}
|
|
|
+ poster={iconVideoBg}
|
|
|
webkit-playsinline
|
|
|
playsinline
|
|
|
x5-video-player-type="h5"
|
|
|
onLoadedmetadata={() => {
|
|
|
data.videoState = 'pause'
|
|
|
- changePlayBtn('play');
|
|
|
+ changePlayBtn('play')
|
|
|
nextTick(() => {
|
|
|
- data.videoContianerRef.currentTime = 0;
|
|
|
+ data.videoContianerRef.currentTime = 0
|
|
|
nextTick(handlePlayVideo)
|
|
|
})
|
|
|
}}
|
|
|
onPlay={() => {
|
|
|
- videoErrorCount = 0;
|
|
|
+ videoErrorCount = 0
|
|
|
console.log('开始播放')
|
|
|
data.videoState = 'play'
|
|
|
changePlayBtn('pause')
|