index-67cc32fc.js 2.7 KB

1
  1. import{d as e,g as i,r as t,o as a,s as n,H as s,v as r,c as o,M as d,Q as l,R as u,S as m,U as c,L as p,n as v,V as g,W as M,O as S,X as _,Y as x,Z as I}from"./instrument-aedeb397.js";import"./node_modules-c5a1f0d3.js";import"./src-2c7b9553.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=i(),b=t({isLoading:!0,currentTime:0,totalTime:0,backgroundRendMode:""}),h=e=>{var i,t,a,s;let r={};try{r="string"==typeof(null==e?void 0:e.data)?JSON.parse(e.data):e.data}catch(o){console.error("parse_error: Invalid JSON data received")}if("api_play"===(null==r?void 0:r.api)&&(n.playState="play",P()),"api_paused"===(null==r?void 0:r.api)){const e=null==(i=null==r?void 0:r.content)?void 0:i.currentTime;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==r?void 0:r.api)&&(n.playState,"paused"===n.playState&&(b.currentTime=null!=(a=null==(t=null==r?void 0:r.content)?void 0:t.currentTime)?a:b.currentTime,n.activeNoteIndex=0,n.activeMeasureIndex=n.times[0].MeasureNumberXML,f(!0))),"api_playProgress"===(null==r?void 0:r.api)){const e=null==(s=null==r?void 0:r.content)?void 0:s.currentTime;if(e){if(e<b.currentTime){n.activeNoteIndex=0;let i=l(e)||n.times[0];i.i===n.activeNoteIndex&&(n.activeMeasureIndex=i.MeasureNumberXML);e<=n.times[0].fixtime&&u(!0)}b.currentTime=e}}};a((async()=>{const i=e.id||"";b.backgroundRendMode=e.backgroundRendMode,n.isSimplePage=!0,n.partIndex=e["part-index"]?Number(e["part-index"]):0,await s(i,"open"),b.isLoading=!1,n.isSingleLine=!0,window.addEventListener("message",h)})),r((()=>{n.isSimplePage=!1,window.removeEventListener("message",h)}));const w=async e=>{var i;const t=null==(i=document.getElementById("scrollContainer"))?void 0:i.getBoundingClientRect().height;n.osmd=e,0===n.originSpeed&&(n.originSpeed=n.speed=e.bpm||e.Sheet.userStartTempoInBPM||100);const a=(m.get("speeds")||{})[n.examSongId]||n.speed||e.bpm||e.Sheet.userStartTempoInBPM;a&&c(a),n.times=p(e),n.times,v((()=>{n.activeMeasureIndex=n.times[0].MeasureNumberXML})),g(n.times),M(),S(),window.parent.postMessage({api:"api_musicPage",height:t},"*"),_({height:t})},f=e=>{const i=b.currentTime;let t=l(i)||n.times[0];t&&x(t,e),n.activeNoteIndex=(null==t?void 0:t.i)||0,n.isSingleLine&&I(i,!0)},P=()=>{if("play"!==n.playState)return;let e=Date.now();requestAnimationFrame((()=>{Date.now()-e<16.7?(f(),P()):setTimeout((()=>{f(),P()}),16.7)}))};return()=>o("div",{class:[T,"video"===b.backgroundRendMode&&N]},[o("div",{class:y},null),o("div",{id:"scrollContainer",class:[L]},[!b.isLoading&&o(d,{onRendered:w,musicColor:"#000000"},null)])])}});export{b as default};