1 |
- import{d as M,g as x,r as y,o as h,s as e,J as N,x as b,b as d,M as w,R as _,S as f,U as k,V as L,W as B,X as P,O as R,n as C,Y as D,Z as X,Q as A,_ as E,$ as J,a0 as O}from"./instrument-44e90045.js";const V="_skeleton_li4n4_4",q="_detail_li4n4_15",I="_mask_li4n4_23",Q="_container_li4n4_29",U="_whiteBg_li4n4_48",l={skeleton:V,detail:q,mask:I,container:Q,whiteBg:U},G=M({name:"simple-detail",setup(){const r=x(),n=y({isLoading:!0,currentTime:0,totalTime:0,backgroundRendMode:""}),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(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=(p=(o=t==null?void 0:t.content)==null?void 0:o.currentTime)!=null?p:n.currentTime,e.activeNoteIndex=0,e.activeMeasureIndex=e.times[0].MeasureNumberXML,c(!0))),(t==null?void 0:t.api)==="api_playProgress"){const s=(g=t==null?void 0:t.content)==null?void 0:g.currentTime;if(s){if(s<n.currentTime){e.activeNoteIndex=0;let S=_(s)||e.times[0];S.i===e.activeNoteIndex&&(e.activeMeasureIndex=S.MeasureNumberXML);const T=e.times[0].fixtime;s<=T&&f(!0)}n.currentTime=s}}};h(async()=>{const a=r.id||"";n.backgroundRendMode=r.backgroundRendMode,e.isSimplePage=!0,e.partIndex=r["part-index"]?Number(r["part-index"]):0,await N(a,"open"),n.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=(k.get("speeds")||{})[e.examSongId]||e.speed||a.bpm||a.Sheet.userStartTempoInBPM;i&&L(i),B(),P(),e.times=R(a),console.log("🚀 ~ state.times:",e.times,e),C(()=>{e.activeMeasureIndex=e.times[0].MeasureNumberXML}),D(e.times),X(),A(),console.log("渲染完成",t),window.parent.postMessage({api:"api_musicPage",height:t},"*"),E({height:t})},c=a=>{const t=n.currentTime;let i=_(t)||e.times[0];i&&J(i,a),e.activeNoteIndex=(i==null?void 0:i.i)||0,e.isSingleLine&&O(t,!0)},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()=>d("div",{class:[l.detail,n.backgroundRendMode==="video"&&l.whiteBg]},[d("div",{class:l.mask},null),d("div",{id:"scrollContainer",class:[l.container]},[!n.isLoading&&d(w,{onRendered:v,musicColor:"#000000"},null)])])}});export{G as default};
|