fix(player): a library item played from the start keeps its point
A cached file that autoplays from 0:00 fires its one playing event before the resume hook subscribes, so the hook never counted it as played and reported nothing - not on pause, not on close. An element already playing when the hook subscribes now counts as played.
This commit is contained in:
@@ -94,6 +94,18 @@ describe("useResume", () => {
|
||||
expect(save).toHaveBeenLastCalledWith(42, 600, true);
|
||||
});
|
||||
|
||||
it("counts an element already playing when it subscribes as played", () => {
|
||||
// A cached file started from 0 autoplays before the effect runs: its one `playing` is gone.
|
||||
const m = fakeMedia();
|
||||
m.metadata();
|
||||
m.play();
|
||||
const save = vi.fn();
|
||||
renderHook(() => useResume(m.el, "7", 0, save));
|
||||
m.at(42);
|
||||
m.pause();
|
||||
expect(save).toHaveBeenLastCalledWith(42, 600, false);
|
||||
});
|
||||
|
||||
it("checkpoints while it plays, at most once per interval", () => {
|
||||
vi.useFakeTimers();
|
||||
const m = fakeMedia();
|
||||
|
||||
Reference in New Issue
Block a user