index-7530bafe.js 2.9 KB

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