(private api: alphaTab.AlphaTabApi)
| 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; |
nothing calls this directly
no test coverage detected