PlayerHandletype
A player on the page.
Import it
import type { PlayerHandle } from "@johnmorrisdotca/kyuubu/player";
Definition
type PlayerHandle = {
readonly plan: ReplayPlan | null;
readonly fault: ReplayFault | null;
load(source: ReplaySource, how?: {
speed?: number;
loop?: boolean;
controls?: boolean;
autoplay?: boolean;
guide?: boolean;
}): void;
play(): void;
pause(): void;
step(by: 1 | -1): void;
seek(position: number): void;
restart(): void;
setSpeed(speed: number): void;
setLoop(loop: boolean): void;
setLocale(locale: KyuubuLanguage): void;
setTheme(theme: CubeTheme): void;
setAnimateScrub(on: boolean): void;
readonly animatingScrub: boolean;
follow(on: boolean): void;
readonly following: boolean;
readonly status: ReplayStatus | null;
destroy(): void;
};
Members
| Name | Type | Description |
|---|---|---|
plan | ReplayPlan | null | The solve as it was read, or why it could not be. |
fault | ReplayFault | null | |
load | (source: ReplaySource, how?: { speed?: number; loop?: boolean; controls?: boolean; autoplay?: boolean; guide?: boolean; }): void | Another solve on the same cube, in place of the one showing. The speed and the repeat are kept unless given. |
play | (): void | |
pause | (): void | |
step | (by: 1 | -1): void | One step on (1) or back (-1). |
seek | (position: number): void | To the cube after this many steps. |
restart | (): void | |
setSpeed | (speed: number): void | |
setLoop | (loop: boolean): void | |
setLocale | (locale: KyuubuLanguage): void | |
setTheme | (theme: CubeTheme): void | |
setAnimateScrub | (on: boolean): void | Whether moving the slider turns the cube between where it was and where it goes. |
animatingScrub | boolean | Whether it does. |
follow | (on: boolean): void | Hand the cube to the viewer to turn, the next move shown on it (true), or take it back to be played (false). |
following | boolean | Whether the viewer is turning it themselves. |
status | ReplayStatus | null | |
destroy | (): void | Take it off the page, with every listener. |
Examples
import type { PlayerHandle } from "@johnmorrisdotca/kyuubu/player";
import { mountPlayer } from "@johnmorrisdotca/kyuubu/player";
const value: PlayerHandle = mountPlayer(document.createElement("div"), { scramble: "R", solution: "R'", autoplay: false });
console.log(value.plan?.solved);