index-adbede44.js 2.8 KB

1
  1. import{d as y,g as _,n as h,c as M,m as e,bK as x,ad as N,h as c,at as f,bO as S,bP as w,$ as L,U as P,bQ as C,bR as k,aB as B,aE as F,bS as D,bT as R,aF as X,bU as E,bV as A,bW as O,bX as U}from"./index-869e4f95.js";const V="_skeleton_bwm6i_4",q="_detail_bwm6i_15",J="_mask_bwm6i_23",Q="_container_bwm6i_29",l={skeleton:V,detail:q,mask:J,container:Q},G=y({name:"simple-detail",setup(){const T=_(),n=h({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 b=e.times[0].fixtime;s<=b&&w(!0)}n.currentTime=s}}};M(async()=>{const a=T.id||"";e.isSimplePage=!0,await x(a,"open"),n.isLoading=!1,e.isSingleLine=!0,window.addEventListener("message",d)}),N(()=>{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&&P(i),C(),k(),e.times=B(a),console.log("🚀 ~ state.times:",e.times,e),F(()=>{e.activeMeasureIndex=e.times[0].MeasureNumberXML,U()}),D(e.times),R(),X(),console.log("渲染完成",t),window.parent.postMessage({api:"api_musicPage",height:t},"*"),E({height:t})},r=a=>{const t=n.currentTime;let i=S(t)||e.times[0];i&&A(i,a),e.activeNoteIndex=(i==null?void 0:i.i)||0,e.isSingleLine&&O(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(f,{onRendered:v,musicColor:"#FFFFFF"},null)])])}});export{G as default};