video.fd7aeb7d.js 5.8 KB

1
  1. import{s as n}from"./video.module.8db9400d.js";import{d as A,ah as I,ag as D,r as T,R as b,Z as S,$ as P,m as f,b3 as R,c as a,L as q,q as s,B as k,f as N}from"./index.7f5edec8.js";import{P as M}from"./plyr.min.22fd58dd.js";/* empty css */import{q as V}from"./index.339fc024.js";import{u as F,b as x}from"./index.5daafe70.js";var Z=A({name:"pre-register",setup(){const v=I(),g=D(),E=sessionStorage.getItem("active-open-id"),p=F(1e3,{controls:!0});p.pause();const e=T({coverImg:"",introductionVideo:"",videoBrowsePoint:0,saveId:v.query.saveId,orchestraId:v.query.id,openId:v.query.openId||E,loading:!1,player:null,playerSpeed:1,intervalFnRef:null}),t=F(1e3,{controls:!0});t.pause();const B=u=>{const r=[];u.sort((l,c)=>l[0]-c[0]);let o=u[0];for(let l=1;l<u.length;l++){const c=u[l];o[1]>=c[0]?o[1]=Math.max(c[1],o[1]):(r.push(o),o=c)}return r.push(o),r},h=u=>{const r=B(u);let o=0;return r.forEach(l=>{o+=l[1]-l[0]}),o},C=()=>{const r={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};N().iPhone&&(r.fullscreen={enabled:!0,fallback:"force",iosNative:!0}),e.player=new M("#register-video",r),e.player.on("loadedmetadata",()=>{console.log("loadedmetadata"),e.loading=!1,e.player.currentTime=e.videoBrowsePoint}),e.player.on("ratechange",()=>{e.playerSpeed=e.playerSpeed<e.player.speed?e.player.speed:e.playerSpeed}),e.player.on("seeking",o=>{t.isActive.value&&t.pause()}),e.player.on("seeked",o=>{t.isActive.value&&t.pause()}),e.player.on("waiting",()=>{t.isActive.value&&t.pause()}),e.player.on("timeupdate",()=>{!t.isActive.value&&e.player.currentTime>0&&e.player.playing&&t.resume()}),e.player.on("ended",()=>{e.player.pause()}),e.player.on("play",()=>{console.log("play"),t.isActive.value||t.resume()}),e.player.on("pause",()=>{console.log("pause"),t.pause()}),e.player.on("enterfullscreen",()=>{console.log("fullscreen");const o=document.createElement("i");o.id="fullscreen-back",o.className="van-icon van-icon-arrow-left video-back",o.addEventListener("click",()=>{e.player.fullscreen.exit()}),console.log(document.getElementsByClassName("plyr")),document.getElementsByClassName("plyr")[0].appendChild(o)}),e.player.on("exitfullscreen",()=>{console.log("exitfullscreen");const o=document.getElementById("fullscreen-back");o&&o.remove()})},d=b([]);let i=[];const m=F(1e3,{controls:!0});S(()=>t.isActive.value,u=>{if(u?i[0]=Math.floor(e.player.currentTime):i[1]=Math.floor(e.player.currentTime),i.length>=2){const r=i[1]-i[0]-m.counter.value*e.playerSpeed>2;i[1]>=i[0]&&!r&&d.value.push(i),i=[],m.counter.value=0}});const y=async(u=10)=>{try{const r=d.value.length>0?B(d.value):[],o=d.value.length>0?h(d.value):0,l=e.player.duration,c=Math.floor(o/Math.floor(l)*100);await f.post("/api-student/open/studentBrowseRecord/updateStat",{data:{id:e.saveId,pageBrowseTime:u,videoBrowseData:JSON.stringify(r),videoBrowseDataTime:o||0,videoBrowsePercentage:c||0,videoBrowseTime:t==null?void 0:t.counter.value,videoBrowsePoint:Math.floor(e.player.currentTime||0)}})}catch{}},w=async()=>{var u,r;try{(u=e.intervalFnRef)==null||u.pause(),m.pause(),p.pause(),await y(),window.location.href=window.location.origin+window.location.pathname+"/project/preRegister.html?"+V.stringify({orchestraId:e.orchestraId,openId:e.openId})}catch(o){console.log(o,"e"),(r=e.intervalFnRef)==null||r.resume(),p.resume(),m.resume()}};return P(async()=>{try{const{data:u}=await f.get("/api-student//open/studentBrowseRecord/query",{params:{openId:e.openId,orchestraId:e.orchestraId}});e.videoBrowsePoint=u.videoBrowsePoint||0,e.player&&(e.player.currentTime=u.videoBrowsePoint||0),e.introductionVideo=u.introductionVideo,e.coverImg=u.coverImg,console.log(u),d.value=u.videoBrowseData?JSON.parse(u.videoBrowseData):[],C(),e.intervalFnRef=x(async()=>{p.counter.value=0,p.resume(),await y(),t.counter.value=0},1e4)}catch{}}),R(()=>{var u;(u=e.intervalFnRef)==null||u.pause(),m.pause(),p.pause()}),e.openId||g.replace({path:"/pre-register-video",query:{id:e.orchestraId}}),()=>a("div",{class:n["pre-register-video"]},[a("div",{class:n.videoContainer},[a("div",{class:n["video-content"]},[a("video",{id:"register-video",class:n.video,src:e.introductionVideo+"?time"+Date.now(),playsinline:!0,poster:e.coverImg,preload:"auto"},null),e.loading&&a("div",{class:n.loadingVideo},[a(q,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[s("\u52A0\u8F7D\u4E2D...")]})])])]),a("div",{class:n.messageContainer},[a("div",{class:n.messageContent},[a("p",null,[s("\u5BB6\u957F\u60A8\u597D\uFF01")]),a("p",{class:n.c1},[s("\u8BF7\u5BB6\u957F\u4EEC\u5408\u7406\u5B89\u6392\u65F6\u95F4\uFF0C"),a("span",null,[s("\u8BA4\u771F\u89C2\u770B")]),s("\u5BB6\u957F\u4F1A\u5185\u5BB9\u3002\u5728"),a("span",null,[s("\u8BE6\u7EC6\u4E86\u89E3")]),s("\u6240\u6709\u8981\u6C42\u540E\uFF0C\u6709\u610F\u5411\u8BA9\u5B69\u5B50\u52A0\u5165\u4E50\u56E2\u7684\u5BB6\u957F\uFF0C\u8BF7\u5728"),a("span",null,[s("\u660E\u665A20:00\u524D")]),s("\uFF0C\u4E3A\u5B69\u5B50\u5B8C\u6210"),a("span",null,[s("\u4E50\u56E2\u62A5\u540D")]),s("\u3002")]),a("p",{class:n.c1},[s("\u4E0B\u5468\uFF0C\u4E13\u4E1A\u8001\u5E08\u5C06\u9488\u5BF9\u610F\u5411\u5165\u56E2\u5B66\u5458\u8FDB\u884C\u8EAB\u4F53\u6761\u4EF6\u786E\u8BA4\u3002\u8C22\u8C22\u5404\u4F4D\u7684\u652F\u6301\uFF01")]),a("p",{class:n.bottom},[s("\u6CE8\uFF1A\u4E50\u56E2\u4E8E\u4E0B\u5B66\u671F\u6B63\u5F0F\u5F00\u59CB\u8BAD\u7EC3\uFF0C\u8BAD\u7EC3\u65F6\u95F4\u4E0B\u5B66\u671F\u5F00\u5B66\u524D\u53E6\u884C\u901A\u77E5\uFF0C\u8BAD\u7EC3\u65F6\u95F4\u4F1A\u4E0E\u5B66\u6821\u5176\u4ED6\u793E\u56E2\u9519\u5F00\uFF0C\u5BB6\u957F\u65E0\u9700\u62C5\u5FC3\u65F6\u95F4\u51B2\u7A81\u95EE\u9898\u3002")])]),a(k,{class:n.submitBtn,onClick:w},null)])])}});export{Z as default};