index-74be86e7.js 2.8 KB

1
  1. import{d as y,g as h,n as M,c as b,m as e,bU as x,ad as N,h as r,at as f,bX as S,bY as w,$ as L,U as C,bZ as P,b_ as k,aB as B,aE as F,b$ as D,c0 as X,aF as E,c1 as R,c2 as A,c3 as U,c4 as q}from"./index-e8c6ad43.js";const J="_skeleton_bwm6i_4",O="_detail_bwm6i_15",V="_mask_bwm6i_23",$="_container_bwm6i_29",l={skeleton:J,detail:O,mask:V,container:$},H=y({name:"simple-detail",setup(){const T=h(),n=M({isLoading:!0,currentTime:0,totalTime:0}),d=a=>{var i,o,u,p;let t={};try{t=typeof(a==null?void 0:a.data)=="string"?JSON.parse(a.data):a.data}catch(s){console.error("parse_error: Invalid JSON data received")}if((t==null?void 0:t.api)==="api_play"&&(console.log("h5开始播放"),e.playState="play",m()),(t==null?void 0:t.api)==="api_paused"){const s=(i=t==null?void 0:t.content)==null?void 0:i.currentTime;console.log("暂停播放",s),e.playState="paused",s===0&&setTimeout(()=>{n.currentTime=0,e.activeNoteIndex=0,e.activeMeasureIndex=e.times[0].MeasureNumberXML,c(!0)},200)}if((t==null?void 0:t.api)==="api_updateProgress"&&(console.log("拖动的进度",e.playState),e.playState==="paused"&&(n.currentTime=(u=(o=t==null?void 0:t.content)==null?void 0:o.currentTime)!=null?u:n.currentTime,e.activeNoteIndex=0,e.activeMeasureIndex=e.times[0].MeasureNumberXML,c(!0))),(t==null?void 0:t.api)==="api_playProgress"){const s=(p=t==null?void 0:t.content)==null?void 0:p.currentTime;if(s){if(s<n.currentTime){e.activeNoteIndex=0;let g=S(s)||e.times[0];g.i===e.activeNoteIndex&&(e.activeMeasureIndex=g.MeasureNumberXML);const _=e.times[0].fixtime;s<=_&&w(!0)}n.currentTime=s}}};b(async()=>{const a=T.id||"";e.isSimplePage=!0,await x(a,"open"),n.isLoading=!1,e.isSingleLine=!0,window.addEventListener("message",d)}),N(()=>{e.isSimplePage=!1,window.removeEventListener("message",d)});const v=async a=>{var o;const t=(o=document.getElementById("scrollContainer"))==null?void 0:o.getBoundingClientRect().height;e.osmd=a,e.originSpeed===0&&(e.originSpeed=e.speed=a.bpm||a.Sheet.userStartTempoInBPM||100);const i=(L.get("speeds")||{})[e.examSongId]||e.speed||a.bpm||a.Sheet.userStartTempoInBPM;i&&C(i),P(),k(),e.times=B(a),console.log("🚀 ~ state.times:",e.times,e),F(()=>{e.activeMeasureIndex=e.times[0].MeasureNumberXML,q()}),D(e.times),X(),E(),console.log("渲染完成",t),window.parent.postMessage({api:"api_musicPage",height:t},"*"),R({height:t})},c=a=>{const t=n.currentTime;let i=S(t)||e.times[0];i&&A(i,a),e.activeNoteIndex=(i==null?void 0:i.i)||0,e.isSingleLine&&U(t)},m=()=>{if(e.playState!=="play"){console.log("暂停播放");return}let a=Date.now();requestAnimationFrame(()=>{Date.now()-a<16.7?(c(),m()):setTimeout(()=>{c(),m()},16.7)})};return()=>r("div",{class:l.detail},[r("div",{class:l.mask},null),r("div",{id:"scrollContainer",class:[l.container,"hideCursor"]},[!n.isLoading&&r(f,{onRendered:v,musicColor:"#FFFFFF"},null)])])}});export{H as default};