video.6777f29d.js 6.8 KB

1
  1. import{d as k,ah as A,ag as F,aY as M,r as q,R as L,Z as I,$ as x,m as N,b3 as B,c as i,L as H,q as O,B as U,f as _,be as $}from"./index.fdfd632c.js";import{s as d}from"./video.module.2569ebf7.js";import{P as j}from"./plyr.min.22fd58dd.js";/* empty css */import{d as V}from"./deep-clone.c5af4e6b.js";import{u as g,b as G}from"./index.2ffb8f7c.js";var W=k({name:"pre-register",setup(){const f=A(),C=F(),E=M(),P=sessionStorage.getItem("active-open-id"),c=g(1e3,{controls:!0});c.pause();const e=q({coverImg:"",introductionVideo:"",introductionVideoTime:0,videoBrowsePoint:0,saveId:f.query.saveId,orchestraId:f.query.id,openId:f.query.openId||P,loading:!1,player:null,playerSpeed:1,intervalFnRef:null,videoDetails:[],pointVideo:{},pointVideoTime:0,videoSelectId:null,isPageHide:!1,parentConferencesNotes:"",orchestraRegisterType:"",status:""}),n=g(1e3,{controls:!0});n.pause();const m=o=>{const a=[];o.sort((r,s)=>r[0]-s[0]);let t=o[0];for(let r=1;r<o.length;r++){const s=o[r];t[1]>=s[0]?t[1]=Math.max(s[1],t[1]):(a.push(t),t=s)}return a.push(t),R(a)},R=o=>{const a=[],t=e.pointVideo.startNode,r=e.pointVideo.endNode;return o.forEach(s=>{s[1]>=s[0]&&(s[0]>=t&&s[0]<=r&&s[1]<=r&&a.push(s),s[0]>=t&&s[0]<=r&&s[1]>r&&a.push([s[0],r]),s[0]<t&&s[1]>t&&s[1]<=r&&a.push([t,s[1]]),s[0]<t&&s[1]>t&&s[1]>r&&a.push([t,r]))}),a},S=o=>{const a=m(o);let t=0;return a.forEach(r=>{t+=r[1]-r[0]}),t},u=o=>{e.videoDetails.forEach(a=>{a.startNode<=o&&o<=a.endNode&&(e.videoSelectId=a.id)})},D=()=>{const a={controls:["play-large","play","progress","captions","current-time","duration","settings","fullscreen"],settings:["speed"],speed:{selected:1,options:[.5,1,1.5,2]},i18n:{speed:"\u901F\u5EA6",normal:"\u9ED8\u8BA4"},autoplay:!1,invertTime:!1};_().iPhone&&(a.fullscreen={enabled:!0,fallback:"force",iosNative:!0});const t=[];e.videoDetails.forEach(r=>{t.push({time:r.startNode,label:r.desc})}),a.markers={enabled:!0,points:t},e.player=new j("#register-video",a),e.player.on("ready",r=>{}),e.player.on("loadedmetadata",()=>{console.log("loadedmetadata"),e.loading=!1,e.player.currentTime=e.videoBrowsePoint,u(e.player.currentTime)}),e.player.on("ratechange",()=>{e.playerSpeed=e.playerSpeed<e.player.speed?e.player.speed:e.playerSpeed}),e.player.on("seeking",()=>{console.log("seeking"),n.isActive.value&&n.pause()}),e.player.on("seeked",()=>{console.log("seeked"),n.isActive.value&&n.pause()}),e.player.on("waiting",()=>{n.isActive.value&&n.pause()}),e.player.on("timeupdate",()=>{u(e.player.currentTime),!n.isActive.value&&e.player.currentTime>0&&e.player.playing&&n.resume()}),e.player.on("ended",()=>{e.player.pause(),console.log(n.isActive.value,"ended")}),e.player.on("play",()=>{console.log("play"),n.resume()}),e.player.on("pause",()=>{console.log("pause",n.isActive.value),n.pause()}),e.player.on("enterfullscreen",()=>{console.log("fullscreen");const r=document.createElement("i");r.id="fullscreen-back",r.className="van-icon van-icon-arrow-left video-back",r.addEventListener("click",()=>{e.player.fullscreen.exit()}),document.getElementsByClassName("plyr")[0].appendChild(r)}),e.player.on("exitfullscreen",()=>{console.log("exitfullscreen");const r=document.getElementById("fullscreen-back");r&&r.remove()}),u(0)},v=L([]);let l=[];const p=g(1e3,{controls:!0});I(()=>n.isActive.value,o=>{y(o)});const y=(o,a=!1)=>{const t=V(l);if(a?l.length>0&&(l[1]=Math.floor(e.player.currentTime)):o?l[0]=Math.floor(e.player.currentTime):l[1]=Math.floor(e.player.currentTime),l.length>=2){const r=l[1]-l[0]-p.counter.value*e.playerSpeed>2;l[1]>=l[0]&&!r&&v.value.push(l),a?l=V(t):(l=[],p.counter.value=0)}};I(E,o=>{console.log("watch",o),o=="hidden"&&e.player.pause()});const h=async(o=10)=>{try{const a=v.value.length>0?m(v.value):[],t=a.length>0?S(a):0,r=Math.floor(t/Math.floor(e.pointVideoTime)*100);await N.post("/api-student/open/studentBrowseRecord/updateStat",{data:{id:e.saveId,pageBrowseTime:o,videoBrowseData:JSON.stringify(a),videoBrowseDataTime:t||0,videoBrowsePercentage:r||0,videoBrowseTime:n==null?void 0:n.counter.value,videoBrowsePoint:Math.floor(e.player.currentTime||0)}})}catch{}},b=async()=>{var o,a;try{e.player.pause(),(o=e.intervalFnRef)==null||o.pause(),p.pause(),n.pause(),c.pause(),y(n.isActive.value),await h(),console.log(e.orchestraRegisterType),e.orchestraRegisterType==="PARENT_CONFERENCES"?window.location.href=window.location.origin+window.location.pathname+`/#/preApply?id=${e.orchestraId}`:e.orchestraRegisterType==="GROUP_BUY"?window.location.href=window.location.origin+window.location.pathname+`/#/preGoodsApply?id=${e.orchestraId}`:window.location.href=window.location.origin+window.location.pathname+"/project/preRegister.html?"+$.stringify({orchestraId:e.orchestraId,openId:e.openId})}catch(t){console.log(t,"e"),(a=e.intervalFnRef)==null||a.resume(),c.resume(),p.resume()}};x(async()=>{try{const{data:o}=await N.get("/api-student/open/studentBrowseRecord/query",{params:{openId:e.openId,orchestraId:e.orchestraId}});e.videoBrowsePoint=o.videoBrowsePoint||0,e.player&&(e.player.currentTime=o.videoBrowsePoint||0),e.introductionVideo=o.introductionVideo,e.introductionVideoTime=o.introductionVideoTime,e.coverImg=o.coverImg,v.value=o.videoBrowseData?JSON.parse(o.videoBrowseData):[],e.parentConferencesNotes=o.parentConferencesNotes,e.orchestraRegisterType=o.orchestraRegisterType,(o.videoDetails||[]).forEach(t=>{e.videoDetails.push({startNode:t.startNode,endNode:t.endNode,desc:t.desc,id:t.id}),t.pointFlag&&(e.pointVideo=t,e.pointVideoTime=t.endNode-t.startNode)}),D(),e.intervalFnRef=G(async()=>{c.counter.value=0,c.resume(),y(!1,!0),await h(),n.counter.value=0},1e4)}catch{}}),B(()=>{var o,a;(o=e.player)==null||o.fullscreen.exit(),(a=e.intervalFnRef)==null||a.pause(),p.pause(),c.pause()}),e.openId||C.replace({path:"/pre-register-video",query:{id:e.orchestraId}});const w=()=>{e.isPageHide&&window.location.reload()};window.addEventListener("pageshow",w);const T=()=>{e.isPageHide=!0};return window.addEventListener("pagehide",T),B(()=>{window.removeEventListener("pageshow",w),window.removeEventListener("pagehide",T)}),()=>i("div",{class:d["pre-register-video"]},[i("div",{class:d.videoContainer},[i("div",{class:d["video-content"]},[i("video",{id:"register-video",class:d.video,src:e.introductionVideo,playsinline:!0,poster:e.coverImg,preload:"auto"},null),e.loading&&i("div",{class:d.loadingVideo},[i(H,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[O("\u52A0\u8F7D\u4E2D...")]})])])]),i("div",{class:d.videoCount},[i("div",{class:d.videoTitle},null),i("div",{class:d.videoCountContent},[e.videoDetails.map(o=>i("span",{class:[o.id===e.videoSelectId?d.active:""],onClick:()=>{e.player.currentTime=o.startNode,e.player.play(),e.videoBrowsePoint=o.startNode,u(e.player.currentTime)}},[o.desc]))])]),i("div",{class:d.messageContainer},[i("div",{class:d.messageContent},[i("div",{innerHTML:e.parentConferencesNotes},null),i(U,{class:d.submitBtn,onClick:b},null)])])])}});export{W as default};