-
-
Notifications
You must be signed in to change notification settings - Fork 844
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
At this commit, the V1 API is identical to Legacy API
- Loading branch information
1 parent
a3d7fac
commit 3f12eb2
Showing
14 changed files
with
396 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { PlayerV1 } from "../../public/player"; | ||
import { InnerPlayer, ReadyState } from "./inner"; | ||
import type { DataLoadOptions, URLLoadOptions } from "../../public/config"; | ||
import type { MovieMetadata } from "../../public/player"; | ||
|
||
export class PlayerV1Impl implements PlayerV1 { | ||
#inner: InnerPlayer; | ||
|
||
constructor(inner: InnerPlayer) { | ||
this.#inner = inner; | ||
} | ||
|
||
get onFSCommand(): ((command: string, args: string) => boolean) | null { | ||
return this.#inner.onFSCommand; | ||
} | ||
|
||
set onFSCommand( | ||
value: ((command: string, args: string) => boolean) | null, | ||
) { | ||
this.#inner.onFSCommand = value; | ||
} | ||
|
||
get readyState(): ReadyState { | ||
return this.#inner._readyState; | ||
} | ||
|
||
get metadata(): MovieMetadata | null { | ||
return this.#inner.metadata; | ||
} | ||
|
||
get loadedConfig(): URLLoadOptions | DataLoadOptions | null { | ||
return this.#inner.loadedConfig ?? null; | ||
} | ||
|
||
async reload(): Promise<void> { | ||
await this.#inner.reload(); | ||
} | ||
|
||
async load( | ||
options: string | URLLoadOptions | DataLoadOptions, | ||
isPolyfillElement: boolean = false, | ||
): Promise<void> { | ||
await this.#inner.load(options, isPolyfillElement); | ||
} | ||
|
||
play(): void { | ||
this.#inner.play(); | ||
} | ||
|
||
get isPlaying(): boolean { | ||
return this.#inner.isPlaying; | ||
} | ||
|
||
get volume(): number { | ||
return this.#inner.volume; | ||
} | ||
|
||
set volume(value: number) { | ||
this.#inner.volume = value; | ||
} | ||
|
||
get fullscreenEnabled(): boolean { | ||
return this.#inner.fullscreenEnabled; | ||
} | ||
|
||
get isFullscreen(): boolean { | ||
return this.#inner.isFullscreen; | ||
} | ||
|
||
setFullscreen(isFull: boolean): void { | ||
this.#inner.setFullscreen(isFull); | ||
} | ||
|
||
enterFullscreen(): void { | ||
this.#inner.enterFullscreen(); | ||
} | ||
|
||
exitFullscreen(): void { | ||
this.#inner.exitFullscreen(); | ||
} | ||
|
||
async downloadSwf(): Promise<void> { | ||
await this.#inner.downloadSwf(); | ||
} | ||
|
||
displayMessage(message: string): void { | ||
this.#inner.displayMessage(message); | ||
} | ||
|
||
pause(): void { | ||
this.#inner.pause(); | ||
} | ||
|
||
set traceObserver(observer: ((message: string) => void) | null) { | ||
this.#inner.traceObserver = observer; | ||
} | ||
|
||
get config(): URLLoadOptions | DataLoadOptions | object { | ||
return this.#inner.config; | ||
} | ||
|
||
set config(value: URLLoadOptions | DataLoadOptions | object) { | ||
this.#inner.config = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
import { LegacyRuffleAPI } from "./legacy"; | ||
import { FlashAPI } from "./flash"; | ||
import { PlayerV1 } from "./v1"; | ||
|
||
/** | ||
* A map of API version number, to API interface. | ||
*/ | ||
export type APIVersions = { | ||
1: PlayerV1; | ||
}; | ||
|
||
/** | ||
* A Ruffle player's HTML element. | ||
* | ||
* This is either created through `window.RufflePlayer.latest().createPlayer()`, or polyfilled from a `<embed>`/`<object>` tag. | ||
* | ||
* In addition to usual HTML attributes, this player contains methods and properties that belong to both | ||
* the **Flash JS API** and **legacy Ruffle API**s. | ||
* the **Flash JS API** and **legacy Ruffle API**s. You are strongly discouraged from using them, and should instead | ||
* use `.ruffle(version)` to access a versioned API interface. | ||
*/ | ||
export interface PlayerElement extends HTMLElement, LegacyRuffleAPI, FlashAPI {} | ||
export interface PlayerElement extends HTMLElement, LegacyRuffleAPI, FlashAPI { | ||
/** | ||
* Access a specific version of the Ruffle API. | ||
* If the given version is not supported, an error is thrown. | ||
* | ||
* @param version Version of the API to access. Defaults to 1. | ||
*/ | ||
ruffle<V extends keyof APIVersions = 1>(version?: V): APIVersions[V]; | ||
} |
Oops, something went wrong.