|
@@ -3,78 +3,46 @@ import styles from './index.module.scss'
|
|
import classNames from 'classnames'
|
|
import classNames from 'classnames'
|
|
import useDataUrl from '@/components/ownUse/useDataUrl'
|
|
import useDataUrl from '@/components/ownUse/useDataUrl'
|
|
import { myData } from '@/utils/http'
|
|
import { myData } from '@/utils/http'
|
|
-import { domDelOwnFu, videoLodingNumFu } from '@/utils/xhrVideo'
|
|
|
|
|
|
+import { domDelOwnFu } from '@/utils/utilsSome'
|
|
|
|
+import PanoVideo from './PanoVideo'
|
|
|
|
+import history from '@/utils/history'
|
|
|
|
+import { ArrowRightOutlined } from '@ant-design/icons'
|
|
|
|
|
|
function A2visit() {
|
|
function A2visit() {
|
|
const { dataUrlSame } = useDataUrl()
|
|
const { dataUrlSame } = useDataUrl()
|
|
|
|
|
|
|
|
+ // 初始视频
|
|
|
|
+ const A2baseVideo = useRef<HTMLVideoElement>(null)
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ if (A2baseVideo.current) {
|
|
|
|
+ A2baseVideo.current.play()
|
|
|
|
+ }
|
|
|
|
+ }, 100)
|
|
|
|
+ }, [])
|
|
|
|
+
|
|
// 动画视频的ref
|
|
// 动画视频的ref
|
|
const videoRef = useRef<HTMLVideoElement>(null)
|
|
const videoRef = useRef<HTMLVideoElement>(null)
|
|
|
|
|
|
// 当前视频索引
|
|
// 当前视频索引
|
|
const [videoInd, setVideoInd] = useState(-1)
|
|
const [videoInd, setVideoInd] = useState(-1)
|
|
|
|
|
|
- const [loding, setLoding] = useState(0)
|
|
|
|
-
|
|
|
|
- const lodingIng = useRef(0)
|
|
|
|
-
|
|
|
|
- // 动画视频的总长度
|
|
|
|
- const lodingNumRef = useRef(0)
|
|
|
|
|
|
+ // 待完善
|
|
|
|
+ const [loding, setLoding] = useState(100)
|
|
|
|
|
|
- // 加载完成之后的bolo地址
|
|
|
|
- const videoSrcArrRef = useRef<{ sort: number; name: string }[]>([])
|
|
|
|
-
|
|
|
|
- const [videoSrcArr, setVideoSrcArr] = useState<string[]>([])
|
|
|
|
-
|
|
|
|
- // 通过blob预加载 src为原视频的视频地址
|
|
|
|
- const videoLodingFu = useCallback((src: string, sort: number) => {
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
- const req = new XMLHttpRequest()
|
|
|
|
- req.open('GET', src, true)
|
|
|
|
- req.responseType = 'blob'
|
|
|
|
-
|
|
|
|
- req.onprogress = function (event) {
|
|
|
|
- if (lodingNumRef.current) {
|
|
|
|
- const num = lodingIng.current + event.loaded
|
|
|
|
-
|
|
|
|
- let percent = (num / lodingNumRef.current) * 100
|
|
|
|
-
|
|
|
|
- percent = Number(percent.toFixed(0))
|
|
|
|
-
|
|
|
|
- setLoding(percent)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- req.onload = function (event) {
|
|
|
|
- lodingIng.current += event.total
|
|
|
|
- if (this.status === 200) {
|
|
|
|
- const videoBlob = this.response
|
|
|
|
- const blobSrc = URL.createObjectURL(videoBlob)
|
|
|
|
- videoSrcArrRef.current.push({ sort, name: blobSrc })
|
|
|
|
- if (videoSrcArrRef.current.length === myData.visit.video.length) {
|
|
|
|
- videoSrcArrRef.current = videoSrcArrRef.current.sort((a, b) => a.sort - b.sort)
|
|
|
|
- setVideoSrcArr(videoSrcArrRef.current.map(v => v.name))
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- req.send()
|
|
|
|
- })
|
|
|
|
- }, [])
|
|
|
|
-
|
|
|
|
- const getVideoNum = useCallback(() => {
|
|
|
|
- myData.visit.video.forEach(async v => {
|
|
|
|
- const temp = await videoLodingNumFu(`${dataUrlSame}/${v.name}`)
|
|
|
|
- lodingNumRef.current += temp
|
|
|
|
-
|
|
|
|
- await videoLodingFu(`${dataUrlSame}/${v.name}`, v.sort)
|
|
|
|
- })
|
|
|
|
- }, [dataUrlSame, videoLodingFu])
|
|
|
|
|
|
+ const timeRR = useRef(-1)
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
- if (dataUrlSame) {
|
|
|
|
- getVideoNum()
|
|
|
|
- }
|
|
|
|
- }, [dataUrlSame, getVideoNum])
|
|
|
|
|
|
+ clearInterval(timeRR.current)
|
|
|
|
+ timeRR.current = window.setInterval(() => {
|
|
|
|
+ if (loding >= 100) {
|
|
|
|
+ clearInterval(timeRR.current)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ setLoding(loding + 1)
|
|
|
|
+ }, 30)
|
|
|
|
+ }, [loding])
|
|
|
|
|
|
// 开始之后的过度动画
|
|
// 开始之后的过度动画
|
|
const [overVideo, setOverVideo] = useState(true)
|
|
const [overVideo, setOverVideo] = useState(true)
|
|
@@ -89,8 +57,11 @@ function A2visit() {
|
|
}
|
|
}
|
|
}, [overVideo])
|
|
}, [overVideo])
|
|
|
|
|
|
- // 点击开始
|
|
|
|
|
|
+ // 点击继续
|
|
const btnStart = useCallback(() => {
|
|
const btnStart = useCallback(() => {
|
|
|
|
+ // 待完善-后面删除
|
|
|
|
+ setOverVideo(false)
|
|
|
|
+
|
|
if (loding >= 100) {
|
|
if (loding >= 100) {
|
|
// 播放已经加载好的视频
|
|
// 播放已经加载好的视频
|
|
setVideoInd(0)
|
|
setVideoInd(0)
|
|
@@ -106,6 +77,27 @@ function A2visit() {
|
|
}
|
|
}
|
|
}, [loding])
|
|
}, [loding])
|
|
|
|
|
|
|
|
+ // 点击 跳下一个章节
|
|
|
|
+
|
|
|
|
+ const [lastVideo, setLastVideo] = useState(false)
|
|
|
|
+
|
|
|
|
+ const videoRefLast = useRef<HTMLVideoElement>(null)
|
|
|
|
+
|
|
|
|
+ const lastVideoFu = useCallback(() => {
|
|
|
|
+ setLastVideo(true)
|
|
|
|
+
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ if (videoRefLast.current) {
|
|
|
|
+ videoRefLast.current.play()
|
|
|
|
+ }
|
|
|
|
+ }, 100)
|
|
|
|
+
|
|
|
|
+ // 0.5s之后删除自己
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ domDelOwnFu('.pvBox')
|
|
|
|
+ }, 500)
|
|
|
|
+ }, [])
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<div className={styles.A2visit}>
|
|
<div className={styles.A2visit}>
|
|
{/* 加载页面 */}
|
|
{/* 加载页面 */}
|
|
@@ -114,7 +106,7 @@ function A2visit() {
|
|
<div className='A2baseBtn'>
|
|
<div className='A2baseBtn'>
|
|
<img src={`${dataUrlSame}visit/btn.png`} alt='' />
|
|
<img src={`${dataUrlSame}visit/btn.png`} alt='' />
|
|
<div className='A2Btxt' onClick={btnStart}>
|
|
<div className='A2Btxt' onClick={btnStart}>
|
|
- {loding >= 100 ? '点击开始' : '加载中'}
|
|
|
|
|
|
+ {loding >= 100 ? '点击继续' : '加载中'}
|
|
</div>
|
|
</div>
|
|
{loding >= 100 ? null : (
|
|
{loding >= 100 ? null : (
|
|
<div className='A2Bxian'>
|
|
<div className='A2Bxian'>
|
|
@@ -126,33 +118,78 @@ function A2visit() {
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<video
|
|
<video
|
|
|
|
+ ref={A2baseVideo}
|
|
src={`${dataUrlSame}/${myData.visit.videoSta}`}
|
|
src={`${dataUrlSame}/${myData.visit.videoSta}`}
|
|
playsInline
|
|
playsInline
|
|
muted
|
|
muted
|
|
webkit-playsinline='true'
|
|
webkit-playsinline='true'
|
|
x5-video-player-type='h5'
|
|
x5-video-player-type='h5'
|
|
- autoPlay
|
|
|
|
loop
|
|
loop
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
{/* 过度动画页面 */}
|
|
{/* 过度动画页面 */}
|
|
- {videoInd === 0 ? (
|
|
|
|
- <div className={classNames('A2base2', overVideo ? '' : 'A2baseHide2')}>
|
|
|
|
- <video
|
|
|
|
- ref={videoRef}
|
|
|
|
- src={videoSrcArr[videoInd]}
|
|
|
|
- playsInline
|
|
|
|
- muted
|
|
|
|
- webkit-playsinline='true'
|
|
|
|
- x5-video-player-type='h5'
|
|
|
|
- onEnded={() => setOverVideo(false)}
|
|
|
|
|
|
+ <div hidden={loding < 100} className={classNames('A2base2', overVideo ? '' : 'A2baseHide2')}>
|
|
|
|
+ <video
|
|
|
|
+ ref={videoRef}
|
|
|
|
+ playsInline
|
|
|
|
+ muted
|
|
|
|
+ webkit-playsinline='true'
|
|
|
|
+ x5-video-player-type='h5'
|
|
|
|
+ src={dataUrlSame + myData.visit.videos[videoInd < 0 ? 0 : videoInd]}
|
|
|
|
+ onEnded={() => setOverVideo(false)}
|
|
|
|
+ >
|
|
|
|
+ <source type='video/mp4' />
|
|
|
|
+ Your browser does not support the video tag.
|
|
|
|
+ </video>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ {/* 全景视频 */}
|
|
|
|
+ <div className={classNames('pvBox', lastVideo ? 'pvBoxHide' : '')} hidden={overVideo}>
|
|
|
|
+ <PanoVideo />
|
|
|
|
+ {/* 跳到下一章 */}
|
|
|
|
+ <div className='pvBtn'>
|
|
|
|
+ <img src={`${dataUrlSame}visit/btn.png`} alt='' />
|
|
|
|
+ <div onClick={lastVideoFu}>
|
|
|
|
+ 行拜谒礼
|
|
|
|
+ <ArrowRightOutlined />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div className='pvRRbtn'>
|
|
|
|
+ {/* 漫游 待完善 */}
|
|
|
|
+ <img src={`${dataUrlSame}visit/icon-walk.png`} alt='' />
|
|
|
|
+ {/* 更多 跳新页面 */}
|
|
|
|
+ <img
|
|
|
|
+ onClick={() => history.push('/more')}
|
|
|
|
+ src={`${dataUrlSame}visit/icon-more.png`}
|
|
|
|
+ alt=''
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
- ) : null}
|
|
|
|
|
|
+ </div>
|
|
|
|
|
|
- {/* 全景视频 */}
|
|
|
|
- {overVideo ? null : <div className='A2panoVideo'>全景视频</div>}
|
|
|
|
|
|
+ {/* 最后一个过长动画 */}
|
|
|
|
+ <div className='A2last'>
|
|
|
|
+ <video
|
|
|
|
+ ref={videoRefLast}
|
|
|
|
+ playsInline
|
|
|
|
+ muted
|
|
|
|
+ webkit-playsinline='true'
|
|
|
|
+ x5-video-player-type='h5'
|
|
|
|
+ src={dataUrlSame + myData.visit.lastVideo}
|
|
|
|
+ onEnded={() => history.push('/banquet')}
|
|
|
|
+ >
|
|
|
|
+ <source type='video/mp4' />
|
|
|
|
+ Your browser does not support the video tag.
|
|
|
|
+ </video>
|
|
|
|
+ <div
|
|
|
|
+ className='A1videoLastBtn'
|
|
|
|
+ style={{ backgroundImage: `url(${dataUrlSame}home/quan.png)` }}
|
|
|
|
+ onClick={() => history.push('/banquet')}
|
|
|
|
+ >
|
|
|
|
+ 跳过
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
)
|
|
)
|
|
}
|
|
}
|