1 |
- import{d as _,F as x,W as M,M as h,V as e,c2 as N,aD as b,j as r,aT as f,c3 as T,c4 as w,aq as L,al as P,a$ as k,B,c5 as C,c6 as D,b2 as X,c7 as q,c8 as A,c9 as E,ca as R}from"./index-6f82b769.js";const F="_skeleton_bwm6i_4",I="_detail_bwm6i_15",J="_mask_bwm6i_23",O="_container_bwm6i_29",d={skeleton:F,detail:I,mask:J,container:O},W=_({name:"simple-detail",setup(){const m=x(),s=M({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,c(!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,c(!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 y=e.times[0].fixtime;n<=y&&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 N(a,"open"),s.isLoading=!1,e.isSingleLine=!0,window.addEventListener("message",u)}),b(()=>{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=k(a),console.log("🚀 ~ state.times:",e.times,e),B(()=>{e.activeMeasureIndex=e.times[0].MeasureNumberXML,R()}),C(e.times),D(),X(),console.log("渲染完成",t),window.parent.postMessage({api:"api_musicPage",height:t},"*"),q({height:t})},c=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?(c(),l()):setTimeout(()=>{c(),l()},16.7)})};return()=>r("div",{class:d.detail},[r("div",{class:d.mask},null),r("div",{id:"scrollContainer",class:[d.container,"hideCursor"]},[!s.isLoading&&r(f,{onRendered:v,musicColor:"#000000"},null)])])}});export{W as default};
|