1 |
- import{d as e,g as t,r as i,o as a,s as n,H as s,v as o,c as r,M as l,Q as d,R as u,S as c,U as m,L as p,n as g,V as v,W as M,O as S,X as _,Y as x,Z as I}from"./instrument-8d283b10.js";import"./node_modules-dbbb91f3.js";import"./src-51e11e57.js";const T="_detail_li4n4_15",y="_mask_li4n4_23",L="_container_li4n4_29",N="_whiteBg_li4n4_48",b=e({name:"simple-detail",setup(){const e=t(),b=i({isLoading:!0,currentTime:0,totalTime:0,backgroundRendMode:""}),h=e=>{var t,i,a,s;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开始播放"),n.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),n.playState="paused",0===e&&setTimeout((()=>{b.currentTime=0,n.activeNoteIndex=0,n.activeMeasureIndex=n.times[0].MeasureNumberXML,f(!0)}),200)}if("api_updateProgress"===(null==o?void 0:o.api)&&(console.log("拖动的进度",n.playState),"paused"===n.playState&&(b.currentTime=null!=(a=null==(i=null==o?void 0:o.content)?void 0:i.currentTime)?a:b.currentTime,n.activeNoteIndex=0,n.activeMeasureIndex=n.times[0].MeasureNumberXML,f(!0))),"api_playProgress"===(null==o?void 0:o.api)){const e=null==(s=null==o?void 0:o.content)?void 0:s.currentTime;if(e){if(e<b.currentTime){n.activeNoteIndex=0;let t=d(e)||n.times[0];t.i===n.activeNoteIndex&&(n.activeMeasureIndex=t.MeasureNumberXML);e<=n.times[0].fixtime&&u(!0)}b.currentTime=e}}};a((async()=>{const t=e.id||"";b.backgroundRendMode=e.backgroundRendMode,n.isSimplePage=!0,n.partIndex=e["part-index"]?Number(e["part-index"]):0,await s(t,"open"),b.isLoading=!1,n.isSingleLine=!0,window.addEventListener("message",h)})),o((()=>{n.isSimplePage=!1,window.removeEventListener("message",h)}));const w=async e=>{var t;const i=null==(t=document.getElementById("scrollContainer"))?void 0:t.getBoundingClientRect().height;n.osmd=e,0===n.originSpeed&&(n.originSpeed=n.speed=e.bpm||e.Sheet.userStartTempoInBPM||100);const a=(c.get("speeds")||{})[n.examSongId]||n.speed||e.bpm||e.Sheet.userStartTempoInBPM;a&&m(a),n.times=p(e),console.log("🚀 ~ state.times:",n.times,n),g((()=>{n.activeMeasureIndex=n.times[0].MeasureNumberXML})),v(n.times),M(),S(),console.log("渲染完成",i),window.parent.postMessage({api:"api_musicPage",height:i},"*"),_({height:i})},f=e=>{const t=b.currentTime;let i=d(t)||n.times[0];i&&x(i,e),n.activeNoteIndex=(null==i?void 0:i.i)||0,n.isSingleLine&&I(t,!0)},P=()=>{if("play"!==n.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:[T,"video"===b.backgroundRendMode&&N]},[r("div",{class:y},null),r("div",{id:"scrollContainer",class:[L]},[!b.isLoading&&r(l,{onRendered:w,musicColor:"#000000"},null)])])}});export{b as default};
|