()
| 394 | } |
| 395 | |
| 396 | private async run() { |
| 397 | const state = await this.prepare(); |
| 398 | const previousState = this.playback.state; |
| 399 | this.playback.state = state.paused |
| 400 | ? PlaybackState.Paused |
| 401 | : PlaybackState.Playing; |
| 402 | |
| 403 | // Seek to the given frame |
| 404 | if (state.seek >= 0 || !this.isInUserRange(this.status.frame)) { |
| 405 | const seekFrame = state.seek < 0 ? this.status.frame : state.seek; |
| 406 | const clampedFrame = this.clampRange(seekFrame); |
| 407 | this.logger.profile('seek time'); |
| 408 | await this.playback.seek(clampedFrame); |
| 409 | this.logger.profile('seek time'); |
| 410 | } |
| 411 | // Do nothing if paused |
| 412 | else if (state.paused) { |
| 413 | if ( |
| 414 | state.render || |
| 415 | (state.paused && previousState !== PlaybackState.Paused) |
| 416 | ) { |
| 417 | // Tells the stage to render the current frame |
| 418 | await this.render.dispatch(); |
| 419 | } |
| 420 | |
| 421 | this.request(); |
| 422 | return; |
| 423 | } |
| 424 | |
| 425 | // Simply move forward one frame |
| 426 | else if (this.status.frame < this.endFrame) { |
| 427 | await this.playback.progress(); |
| 428 | } |
| 429 | |
| 430 | // Pause if a new slide has just started. |
| 431 | if (!state.paused && this.playback.currentScene.slides.isWaiting()) { |
| 432 | this.togglePlayback(false); |
| 433 | state.paused = true; |
| 434 | } |
| 435 | |
| 436 | // Draw the project |
| 437 | await this.render.dispatch(); |
| 438 | this.frame.current = this.playback.frame; |
| 439 | |
| 440 | this.request(); |
| 441 | } |
| 442 | |
| 443 | private request() { |
| 444 | if (!this.active) return; |
no test coverage detected