Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

RT3: a film played again from its end is at its start from the call on

shinyobjectz6c390a4a1746
diff --git a/sdk/ui/src/dom/media.ts b/sdk/ui/src/dom/media.ts
index f54a8d7f..787ecca7 100644
--- a/sdk/ui/src/dom/media.ts
+++ b/sdk/ui/src/dom/media.ts
@@ -80,11 +80,14 @@ export class HTMLMediaElement_ extends HTMLElement_ {
}
play() {
if (!this._playing) {
+ // played to its end, it starts again from the start, as a browser's does, and currentTime is 0 from now: it was
+ // left at the end until the host's first frame came, so a pause before then paused it back at the end (11-16)
+ if (this._ended || this._time >= (this.duration || Infinity)) this._time = 0;
this._playing = true;
this._ended = false;
this._tell("__muted", this.muted);
if (this._volume !== undefined) this._tell("__volume", this._volume);
- this._tell("__play", [true, this._time >= (this.duration || Infinity) ? 0 : this._time, ++this._plays, this.loop]);
+ this._tell("__play", [true, this._time, ++this._plays, this.loop]);
dispatchDirect(this, new Event_("play", { bubbles: false }));
}
return Promise.resolve();
diff --git a/sdk/ui/test/dom.test.tsx b/sdk/ui/test/dom.test.tsx
index 14e7897f..f0ca27d4 100644
--- a/sdk/ui/test/dom.test.tsx
+++ b/sdk/ui/test/dom.test.tsx
@@ -364,10 +364,12 @@ describe("video and audio play on the host's player (runtime/dom media.rs, raea-
expect(v.paused).toBe(true);
expect(v.ended).toBe(true);
expect(v.currentTime).toBe(120.6);
- // played again from the end starts at the beginning
+ // played again from the end starts at the beginning, and is there from the call on (a pause before the host's first
+ // frame pauses it at the start, as a browser's does, not back at the end)
v.play();
expect(prop("__play")).toEqual([true, 0, 6, true]);
+ expect(v.currentTime).toBe(0);
// load(): back to the start, paused with no pause event, and the host's decoder opened again
v.load();
@@ -376,7 +378,7 @@ describe("video and audio play on the host's player (runtime/dom media.rs, raea-
expect(v.readyState).toBe(0);
expect(prop("__load")).toBe(1);
expect(prop("__play")).toEqual([false, 0, 7, true]);
- expect(seen.at(-1)).toBe("[email protected]");
+ expect(seen.at(-1)).toBe("[email protected]");
expect(v.canPlayType("video/mp4")).toBe("maybe");
expect(v.canPlayType("video/x-unknown")).toBe("");
});