* Initializes a new instance of the AlphaTabApiBase class. * @param uiFacade The UI facade to use for interacting with the user interface. * @param settings The UI settings object to use for loading the settings.
(uiFacade: IUiFacade<TSettings>, settings: TSettings)
| 348 | * @param settings The UI settings object to use for loading the settings. |
| 349 | */ |
| 350 | public constructor(uiFacade: IUiFacade<TSettings>, settings: TSettings) { |
| 351 | this.uiFacade = uiFacade; |
| 352 | this.container = uiFacade.rootContainer; |
| 353 | |
| 354 | this.activeBeatsChanged = new EventEmitterOfT<ActiveBeatsChangedEventArgs>(() => { |
| 355 | const currentBeat = this._currentBeat; |
| 356 | if (this._player.state === PlayerState.Playing && currentBeat) { |
| 357 | return new ActiveBeatsChangedEventArgs(currentBeat.beatLookup.highlightedBeats.map(h => h.beat)); |
| 358 | } |
| 359 | return null; |
| 360 | }); |
| 361 | this.playedBeatChanged = new EventEmitterOfT<Beat>(() => { |
| 362 | const currentBeat = this._currentBeat; |
| 363 | if (this._player.state === PlayerState.Playing && currentBeat) { |
| 364 | return currentBeat.beat; |
| 365 | } |
| 366 | return null; |
| 367 | }); |
| 368 | this.scoreLoaded = new EventEmitterOfT<Score>(() => { |
| 369 | if (this._score) { |
| 370 | return this._score; |
| 371 | } |
| 372 | return null; |
| 373 | }); |
| 374 | |
| 375 | this.midiLoaded = new EventEmitterOfT<PositionChangedEventArgs>(() => { |
| 376 | return this._player.loadedMidiInfo ?? null; |
| 377 | }); |
| 378 | |
| 379 | uiFacade.initialize(this, settings); |
| 380 | Logger.logLevel = this.settings.core.logLevel; |
| 381 | |
| 382 | this.settings.handleBackwardsCompatibility(); |
| 383 | |
| 384 | Environment.printEnvironmentInfo(false); |
| 385 | |
| 386 | this.canvasElement = uiFacade.createCanvasElement(); |
| 387 | this.container.appendChild(this.canvasElement); |
| 388 | this._renderer = new ScoreRendererWrapper(); |
| 389 | if ( |
| 390 | this.settings.core.useWorkers && |
| 391 | this.uiFacade.areWorkersSupported && |
| 392 | Environment.getRenderEngineFactory(this.settings.core.engine).supportsWorkers |
| 393 | ) { |
| 394 | this._renderer.instance = this.uiFacade.createWorkerRenderer(); |
| 395 | } else { |
| 396 | this._renderer.instance = new ScoreRenderer(this.settings); |
| 397 | } |
| 398 | |
| 399 | this.container.resize.on( |
| 400 | this.uiFacade.throttle(() => { |
| 401 | if (this._isDestroyed) { |
| 402 | return; |
| 403 | } |
| 404 | if (this.container.width !== this._renderer.width) { |
| 405 | this.triggerResize(); |
| 406 | } |
| 407 | }, uiFacade.resizeThrottle) |
nothing calls this directly
no test coverage detected