import { LitElement } from 'lit'; import { FullscreenElement, MediaPlayerController, PIPElement } from '../../types'; import { CachedValueController } from '../cached-value-controller'; export class UpdatingImageMediaPlayerController implements MediaPlayerController { private _host: LitElement; private _getImageCallback: () => HTMLImageElement | null; private _getCachedValueController: () => CachedValueController | null; constructor( host: LitElement, getImageCallback: () => HTMLImageElement | null, getCachedValueController: () => CachedValueController | null, ) { this._host = host; this._getImageCallback = getImageCallback; this._getCachedValueController = getCachedValueController; } public async play(): Promise { await this._host.updateComplete; this._getCachedValueController()?.startTimer(); } public async pause(): Promise { await this._host.updateComplete; this._getCachedValueController()?.stopTimer(); } public async mute(): Promise { // Not implemented. } public async unmute(): Promise { // Not implemented. } public isMuted(): boolean { return true; } // eslint-disable-next-line @typescript-eslint/no-unused-vars public async seek(_seconds: number): Promise { // Not implemented. } // eslint-disable-next-line @typescript-eslint/no-unused-vars public async setControls(_controls: boolean): Promise { // Not implemented. } public isPaused(): boolean { return !this._getCachedValueController()?.hasTimer(); } public async getScreenshotURL(): Promise { await this._host.updateComplete; return this._getCachedValueController()?.getValue() ?? null; } public getFullscreenElement(): FullscreenElement | null { return this._getImageCallback() ?? null; } public getPIPElement(): PIPElement | null { return null; } }