1 |
- import{d as e,g as t,r as i,o as a,s,H as n,v as o,c as r,M as l,Q as d,R as u,S as m,U as c,L as p,n as v,W as g,X as S,O as _,Y as M,Z as x,_ as I,$ as T}from"./instrument-ed268b80.js";import"./node_modules-a057846a.js";import"./src-5174ef10.js";const y="_detail_bwm6i_15",w="_mask_bwm6i_23",L="_container_bwm6i_29",N=e({name:"simple-detail",setup(){const e=t(),N=i({isLoading:!0,currentTime:0,totalTime:0}),h=e=>{var t,i,a,n;let o={};try{o="string"==typeof(null==e?void 0:e.data)?JSON.parse(e.data):e.data}catch(r){console.error("parse_error: Invalid JSON data received")}if("api_play"===(null==o?void 0:o.api)&&(console.log("h5开始播放"),s.playState="play",P()),"api_paused"===(null==o?void 0:o.api)){const e=null==(t=null==o?void 0:o.content)?void 0:t.currentTime;console.log("暂停播放",e),s.playState="paused",0===e&&setTimeout((()=>{N.currentTime=0,s.activeNoteIndex=0,s.activeMeasureIndex=s.times[0].MeasureNumberXML,f(!0)}),200)}if("api_updateProgress"===(null==o?void 0:o.api)&&(console.log("拖动的进度",s.playState),"paused"===s.playState&&(N.currentTime=null!=(a=null==(i=null==o?void 0:o.content)?void 0:i.currentTime)?a:N.currentTime,s.activeNoteIndex=0,s.activeMeasureIndex=s.times[0].MeasureNumberXML,f(!0))),"api_playProgress"===(null==o?void 0:o.api)){const e=null==(n=null==o?void 0:o.content)?void 0:n.currentTime;if(e){if(e<N.currentTime){s.activeNoteIndex=0;let t=d(e)||s.times[0];t.i===s.activeNoteIndex&&(s.activeMeasureIndex=t.MeasureNumberXML);e<=s.times[0].fixtime&&u(!0)}N.currentTime=e}}};a((async()=>{const t=e.id||"";s.isSimplePage=!0,s.partIndex=e["part-index"]?Number(e["part-index"]):0,await n(t,"open"),N.isLoading=!1,s.isSingleLine=!0,window.addEventListener("message",h)})),o((()=>{s.isSimplePage=!1,window.removeEventListener("message",h)}));const b=async e=>{var t;const i=null==(t=document.getElementById("scrollContainer"))?void 0:t.getBoundingClientRect().height;s.osmd=e,0===s.originSpeed&&(s.originSpeed=s.speed=e.bpm||e.Sheet.userStartTempoInBPM||100);const a=(m.get("speeds")||{})[s.examSongId]||s.speed||e.bpm||e.Sheet.userStartTempoInBPM;a&&c(a),s.times=p(e),console.log("🚀 ~ state.times:",s.times,s),v((()=>{s.activeMeasureIndex=s.times[0].MeasureNumberXML,T()})),g(s.times),S(),_(),console.log("渲染完成",i),window.parent.postMessage({api:"api_musicPage",height:i},"*"),M({height:i})},f=e=>{const t=N.currentTime;let i=d(t)||s.times[0];i&&x(i,e),s.activeNoteIndex=(null==i?void 0:i.i)||0,s.isSingleLine&&I(t,!0)},P=()=>{if("play"!==s.playState)return void console.log("暂停播放");let e=Date.now();requestAnimationFrame((()=>{Date.now()-e<16.7?(f(),P()):setTimeout((()=>{f(),P()}),16.7)}))};return()=>r("div",{class:y},[r("div",{class:w},null),r("div",{id:"scrollContainer",class:[L,"hideCursor"]},[!N.isLoading&&r(l,{onRendered:b,musicColor:"#000000"},null)])])}});export{N as default};
|