1 |
- import{d as e,g as a,r as i,o as t,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,V as p,W as v,L as g,n as M,X as _,Y as S,O as x,Z as I,_ as T,$ as y}from"./instrument-30e9a353.js";import"./node_modules-c5a1f0d3.js";import"./src-2c7b9553.js";const L="_detail_li4n4_15",N="_mask_li4n4_23",b="_container_li4n4_29",h="_whiteBg_li4n4_48",w=e({name:"simple-detail",setup(){const e=a(),w=i({isLoading:!0,currentTime:0,totalTime:0,backgroundRendMode:""}),f=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",k()),"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((()=>{w.currentTime=0,n.activeNoteIndex=0,n.activeMeasureIndex=n.times[0].MeasureNumberXML,R(!0)}),200)}if("api_updateProgress"===(null==r?void 0:r.api)&&(n.playState,"paused"===n.playState&&(w.currentTime=null!=(t=null==(i=null==r?void 0:r.content)?void 0:i.currentTime)?t:w.currentTime,n.activeNoteIndex=0,n.activeMeasureIndex=n.times[0].MeasureNumberXML,R(!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<w.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)}w.currentTime=e}}};t((async()=>{const a=e.id||"";w.backgroundRendMode=e.backgroundRendMode,n.isSimplePage=!0,n.partIndex=e["part-index"]?Number(e["part-index"]):0,await s(a,"open"),w.isLoading=!1,n.isSingleLine=!0,window.addEventListener("message",f)})),r((()=>{n.isSimplePage=!1,window.removeEventListener("message",f)}));const P=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=(m.get("speeds")||{})[n.examSongId]||n.speed||e.bpm||e.Sheet.userStartTempoInBPM;t&&c(t),p(),v(),n.times=g(e),n.times,M((()=>{n.activeMeasureIndex=n.times[0].MeasureNumberXML})),_(n.times),S(),x(),window.parent.postMessage({api:"api_musicPage",height:i},"*"),I({height:i})},R=e=>{const a=w.currentTime;let i=l(a)||n.times[0];i&&T(i,e),n.activeNoteIndex=(null==i?void 0:i.i)||0,n.isSingleLine&&y(a,!0)},k=()=>{if("play"!==n.playState)return;let e=Date.now();requestAnimationFrame((()=>{Date.now()-e<16.7?(R(),k()):setTimeout((()=>{R(),k()}),16.7)}))};return()=>o("div",{class:[L,"video"===w.backgroundRendMode&&h]},[o("div",{class:N},null),o("div",{id:"scrollContainer",class:[b]},[!w.isLoading&&o(d,{onRendered:P,musicColor:"#000000"},null)])])}});export{w as default};
|