index-c0fe8f19.js 2.6 KB

1
  1. import{d as e,g as a,r as i,o as t,s as n,J as s,x as r,b as o,M as d,R as l,S as u,U as c,V as m,O as p,n as v,W as g,X as M,Q as S,Y as _,Z as x,_ as I}from"./instrument-72ce6d74.js";const T="_detail_li4n4_15",y="_mask_li4n4_23",b="_container_li4n4_29",N="_whiteBg_li4n4_48",L=e({name:"simple-detail",setup(){const e=a(),L=i({isLoading:!0,currentTime:0,totalTime:0,backgroundRendMode:""}),h=e=>{var a,i,t,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==(a=null==r?void 0:r.content)?void 0:a.currentTime;n.playState="paused",0===e&&setTimeout((()=>{L.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&&(L.currentTime=null!=(t=null==(i=null==r?void 0:r.content)?void 0:i.currentTime)?t:L.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<L.currentTime){n.activeNoteIndex=0;let a=l(e)||n.times[0];a.i===n.activeNoteIndex&&(n.activeMeasureIndex=a.MeasureNumberXML);e<=n.times[0].fixtime&&u(!0)}L.currentTime=e}}};t((async()=>{const a=e.id||"";L.backgroundRendMode=e.backgroundRendMode,n.isSimplePage=!0,n.partIndex=e["part-index"]?Number(e["part-index"]):0,await s(a,"open"),L.isLoading=!1,n.isSingleLine=!0,window.addEventListener("message",h)})),r((()=>{n.isSimplePage=!1,window.removeEventListener("message",h)}));const w=async e=>{var a;const i=null==(a=document.getElementById("scrollContainer"))?void 0:a.getBoundingClientRect().height;n.osmd=e,0===n.originSpeed&&(n.originSpeed=n.speed=e.bpm||e.Sheet.userStartTempoInBPM||100);const t=(c.get("speeds")||{})[n.examSongId]||n.speed||e.bpm||e.Sheet.userStartTempoInBPM;t&&m(t),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:i},"*"),_({height:i})},f=e=>{const a=L.currentTime;let i=l(a)||n.times[0];i&&x(i,e),n.activeNoteIndex=(null==i?void 0:i.i)||0,n.isSingleLine&&I(a,!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"===L.backgroundRendMode&&N]},[o("div",{class:y},null),o("div",{id:"scrollContainer",class:[b]},[!L.isLoading&&o(d,{onRendered:w,musicColor:"#000000"},null)])])}});export{L as default};