index-4abbd465.js 2.8 KB

1
  1. import{d as y,g as _,n as x,c as h,m as e,bR as M,ae as N,h as c,au as f,bS as T,bT as w,a0 as L,V as P,aC as C,aF as k,bU as B,bV as D,aG as X,bW as R,bX as A,bY as E,bZ as V}from"./index-fb099d6d.js";const q="_skeleton_bwm6i_4",F="_detail_bwm6i_15",I="_mask_bwm6i_23",J="_container_bwm6i_29",d={skeleton:q,detail:F,mask:I,container:J},U=y({name:"simple-detail",setup(){const m=_(),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 b=e.times[0].fixtime;n<=b&&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&&P(i),e.times=C(a),console.log("🚀 ~ state.times:",e.times,e),k(()=>{e.activeMeasureIndex=e.times[0].MeasureNumberXML,V()}),B(e.times),D(),X(),console.log("渲染完成",t),window.parent.postMessage({api:"api_musicPage",height:t},"*"),R({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:"#000000"},null)])])}});export{U as default};