Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
529 changes: 529 additions & 0 deletions web/package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions web/packages/core/src/internal/player/impl_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export class PlayerV1Impl implements PlayerV1 {
this.#inner.play();
}

tick(timestamp: number): void {
this.#inner.tick(timestamp);
}

get isPlaying(): boolean {
return this.#inner.isPlaying;
}
Expand Down
16 changes: 16 additions & 0 deletions web/packages/core/src/internal/player/inner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ export class InnerPlayer {
// The effective config loaded upon `.load()`.
public loadedConfig?: URLLoadOptions | DataLoadOptions;

// Whether content should tick automatically or
// require manual calls to tick().
public tickAutomatically: boolean = true;

private swfUrl?: URL;
private instance: RuffleHandle | null;
private newZipWriter: (() => ZipWriter) | null;
Expand Down Expand Up @@ -652,6 +656,7 @@ export class InnerPlayer {
this.newZipWriter = zipWriterClass;
configureBuilder(builder, this.loadedConfig || {});
builder.setVolume(this.volumeSettings.get_volume());
builder.setTickAutomatically(this.tickAutomatically);

if (this.loadedConfig?.fontSources) {
for (const url of this.loadedConfig.fontSources) {
Expand Down Expand Up @@ -935,6 +940,11 @@ export class InnerPlayer {
this.loadedConfig.backgroundColor;
}

this.tickAutomatically =
"__tickAutomatically" in options
? options["__tickAutomatically"] === true
: true;

await this.ensureFreshInstance();

if ("url" in options) {
Expand Down Expand Up @@ -972,6 +982,12 @@ export class InnerPlayer {
}
}

tick(timestamp: number): void {
if (this.instance) {
this.instance.tick_pub(timestamp);
}
}

/**
* Whether this player is currently playing.
*
Expand Down
2 changes: 2 additions & 0 deletions web/packages/core/src/public/player/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,6 @@ export interface PlayerV1 {
* @returns Any value returned by the callback.
*/
callExternalInterface(name: string, ...args: unknown[]): unknown;

tick(timestamp: number): void;
}
2 changes: 2 additions & 0 deletions web/packages/selfhosted/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"@types/chai": "^5.2.2",
"@types/chai-html": "^3.0.0",
"json5": "^2.2.3",
"sharp": "^0.34.4",
"smol-toml": "^1.4.2",
"ts-node": "^10.9.2",
"webpack": "^5.102.0",
"webpack-cli": "^6.0.1",
Expand Down
41 changes: 41 additions & 0 deletions web/packages/selfhosted/test/swf_tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!doctype>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
<div id="container"></div>
<script>
const urlParams = new URLSearchParams(window.location.search);
const swfUrl = urlParams.get('swf');
const name = urlParams.get('name');
document.title = name;
window.RufflePlayer = window.RufflePlayer || {};
window.RufflePlayer.config = {
autoplay: "off",
quality: urlParams.get("config_quality"),
};

window.addEventListener("load", (event) => {
const ruffle = window.RufflePlayer.newest();
const player = ruffle.createPlayer();
const container = document.getElementById("container");
container.appendChild(player);

player.addEventListener("loadedmetadata", () => {
player.style.width = `${player.ruffle().metadata.width}px`;
player.style.height = `${player.ruffle().metadata.height}px`;
});

player.ruffle().load({
url: swfUrl,
__tickAutomatically: false,
});
});
</script>
<script src="/dist/ruffle.js"></script>
</body>

</html>
9 changes: 9 additions & 0 deletions web/packages/selfhosted/test/swf_tests/swf_tests.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// Tests are loaded from the //tests/tests/swfs directory.
// This file contains web-specific configuration of those tests.
// Please order tests alphabetically.
"tests": {
"visual/edittext/edittext_background_basic": {},
"visual/edittext/edittext_border_basic": {},
},
}
Loading
Loading