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,O as B,n as P,W as R,X as C,Q as D,Y as X,Z as A,_ as E}from"./instrument-85ec1a1d.js";const J="_skeleton_li4n4_4",O="_detail_li4n4_15",q="_mask_li4n4_23",I="_container_li4n4_29",Q="_whiteBg_li4n4_48",l={skeleton:J,detail:O,mask:q,container:I,whiteBg:Q},V=M({name:"simple-detail",setup(){const r=x(),n=y({isLoading:!0,currentTime:0,totalTime:0,backgroundRendMode:""}),u=i=>{var a,o,p,g;let t={};try{t=typeof(i==null?void 0:i.data)=="string"?JSON.parse(i.data):i.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=(a=t==null?void 0:t.content)==null?void 0:a.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 i=r.id||"";n.backgroundRendMode=r.backgroundRendMode,e.isSimplePage=!0,e.partIndex=r["part-index"]?Number(r["part-index"]):0,await N(i,"open"),n.isLoading=!1,e.isSingleLine=!0,window.addEventListener("message",u)}),b(()=>{e.isSimplePage=!1,window.removeEventListener("message",u)});const v=async i=>{var o;const t=(o=document.getElementById("scrollContainer"))==null?void 0:o.getBoundingClientRect().height;e.osmd=i,e.originSpeed===0&&(e.originSpeed=e.speed=i.bpm||i.Sheet.userStartTempoInBPM||100);const a=(k.get("speeds")||{})[e.examSongId]||e.speed||i.bpm||i.Sheet.userStartTempoInBPM;a&&L(a),e.times=B(i),console.log("🚀 ~ state.times:",e.times,e),P(()=>{e.activeMeasureIndex=e.times[0].MeasureNumberXML}),R(e.times),C(),D(),console.log("渲染完成",t),window.parent.postMessage({api:"api_musicPage",height:t},"*"),X({height:t})},c=i=>{const t=n.currentTime;let a=_(t)||e.times[0];a&&A(a,i),e.activeNoteIndex=(a==null?void 0:a.i)||0,e.isSingleLine&&E(t,!0)},m=()=>{if(e.playState!=="play"){console.log("暂停播放");return}let i=Date.now();requestAnimationFrame(()=>{Date.now()-i<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{V as default};
|