MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / constructor

Method constructor

packages/playground/src/components/Waveform.ts:41–59  ·  view source on GitHub ↗
(private api: alphaTab.AlphaTabApi)

Source from the content-addressed store, hash-verified

39 private unsubStateChanged: () => void;
40
41 constructor(private api: alphaTab.AlphaTabApi) {
42 this.root = parseHtml(html`
43 <div class="at-waveform hidden">
44 <div class="at-waveform-cursor"></div>
45 </div>
46 `);
47 this.cursor = this.root.querySelector('.at-waveform-cursor')!;
48 this.root.addEventListener('click', e => {
49 if (this.audioElement) {
50 const rect = this.root.getBoundingClientRect();
51 const percent = (e.clientX - rect.left) / rect.width;
52 this.audioElement.currentTime = this.audioElement.duration * percent;
53 }
54 });
55
56 this.unsubScoreLoaded = api.scoreLoaded.on(() => this.refresh());
57 this.unsubPlayerReady = api.playerReady.on(() => this.refresh());
58 this.unsubStateChanged = api.playerStateChanged.on(() => this.refresh());
59 }
60
61 private async refresh(): Promise<void> {
62 const score = this.api.score;

Callers

nothing calls this directly

Calls 5

refreshMethod · 0.95
parseHtmlFunction · 0.90
htmlFunction · 0.90
addEventListenerMethod · 0.65
onMethod · 0.65

Tested by

no test coverage detected