|
@@ -0,0 +1,63 @@
|
|
|
+import React, { useEffect, useRef } from 'react'
|
|
|
+import styles from './index.module.scss'
|
|
|
+import classNames from 'classnames'
|
|
|
+import { domDelOwnFu } from '@/utils/utilsSome'
|
|
|
+import history from '@/utils/history'
|
|
|
+import useDataUrl from '../ownUse/useDataUrl'
|
|
|
+
|
|
|
+type Props = {
|
|
|
+ lastVideo: boolean
|
|
|
+ delDom: string
|
|
|
+ src: string
|
|
|
+ path: string
|
|
|
+}
|
|
|
+
|
|
|
+// 页面结尾的视频
|
|
|
+function EndVideo({ lastVideo, delDom, src, path }: Props) {
|
|
|
+ const { dataUrlSame } = useDataUrl()
|
|
|
+
|
|
|
+ const videoRefLast = useRef<HTMLVideoElement>(null)
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (lastVideo) {
|
|
|
+ setTimeout(() => {
|
|
|
+ if (videoRefLast.current) {
|
|
|
+ videoRefLast.current.play()
|
|
|
+ }
|
|
|
+ }, 100)
|
|
|
+
|
|
|
+ // 0.5s之后删除自己
|
|
|
+ setTimeout(() => {
|
|
|
+ domDelOwnFu(delDom)
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ }, [delDom, lastVideo])
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className={classNames(styles.EndVideo, lastVideo ? styles.EndVideoAc : '')}>
|
|
|
+ <video
|
|
|
+ ref={videoRefLast}
|
|
|
+ playsInline
|
|
|
+ muted
|
|
|
+ webkit-playsinline='true'
|
|
|
+ x5-video-player-type='h5'
|
|
|
+ src={src}
|
|
|
+ onEnded={() => history.push(path)}
|
|
|
+ >
|
|
|
+ <source type='video/mp4' />
|
|
|
+ Your browser does not support the video tag.
|
|
|
+ </video>
|
|
|
+
|
|
|
+ <div
|
|
|
+ title='跳过'
|
|
|
+ className='endVdieoBtn'
|
|
|
+ style={{ backgroundImage: `url(${dataUrlSame}home/tiao.png)` }}
|
|
|
+ onClick={() => history.push(path)}
|
|
|
+ ></div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+const MemoEndVideo = React.memo(EndVideo)
|
|
|
+
|
|
|
+export default MemoEndVideo
|