index-68a37969.js 2.8 KB

1
  1. import{d as y,g as M,r as x,o as h,s as e,J as N,x as f,b as c,M as w,R as S,S as b,U as L,V as C,W as P,X as k,O as B,n as F,Y as D,Z as R,Q as X,_ as A,$ as E,a0 as J,a1 as O}from"./instrument-1f02e47a.js";const V="_skeleton_bwm6i_4",q="_detail_bwm6i_15",Q="_mask_bwm6i_23",U="_container_bwm6i_29",l={skeleton:V,detail:q,mask:Q,container:U},G=y({name:"simple-detail",setup(){const T=M(),n=x({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,r(!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,r(!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<=_&&b(!0)}n.currentTime=s}}};h(async()=>{const a=T.id||"";e.isSimplePage=!0,await N(a,"open"),n.isLoading=!1,e.isSingleLine=!0,window.addEventListener("message",d)}),f(()=>{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,O()}),D(e.times),R(),X(),console.log("渲染完成",t),window.parent.postMessage({api:"api_musicPage",height:t},"*"),A({height:t})},r=a=>{const t=n.currentTime;let i=S(t)||e.times[0];i&&E(i,a),e.activeNoteIndex=(i==null?void 0:i.i)||0,e.isSingleLine&&J(t)},m=()=>{if(e.playState!=="play"){console.log("暂停播放");return}let a=Date.now();requestAnimationFrame(()=>{Date.now()-a<16.7?(r(),m()):setTimeout(()=>{r(),m()},16.7)})};return()=>c("div",{class:l.detail},[c("div",{class:l.mask},null),c("div",{id:"scrollContainer",class:[l.container,"hideCursor"]},[!n.isLoading&&c(w,{onRendered:v,musicColor:"#FFFFFF"},null)])])}});export{G as default};