| 378 | } |
| 379 | |
| 380 | override async didApply({ updateHistory = true, updateState = true } = {}): Promise<ActionApplyResult> { |
| 381 | if (updateHistory === true) { |
| 382 | if (this.player instanceof AudioPlayer || this.mediaKey) { |
| 383 | this.engine.history(this.type).push(this._statement as string); |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | if (updateState === true) { |
| 388 | const currentState = this.engine.state(this.type); |
| 389 | if (this.player instanceof AudioPlayer || this.mediaKey) { |
| 390 | const newItem: MediaStateItem = { statement: this._statement as string, paused: false }; |
| 391 | this.engine.state({ [this.type]: [...currentState, newItem] }); |
| 392 | } else if (this.player instanceof Array) { |
| 393 | const updatedState = currentState.map((item: MediaStateItem) => ({ |
| 394 | ...item, |
| 395 | paused: false |
| 396 | })); |
| 397 | this.engine.state({ [this.type]: updatedState }); |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | return { advance: true }; |
| 402 | } |
| 403 | |
| 404 | override async revert(): Promise<void> { |
| 405 | if (typeof this.mediaKey !== 'undefined') { |