Aero music: start without a tap on the player
"It should play by default when the Frutiger theme loads in." The embed URL now carries auto_play=true as a second try alongside the immediate play() call, and when the browser still refuses (a reload carries no gesture), the retry rides the next pointerdown/keydown anywhere OUTSIDE the player - the first tap on anything starts the music. A 700ms throttle keeps a flurry of taps from skipping through the set, taps on the player's own controls are left to their handlers (no blip on the x), and an explicit pause or dismiss is respected: no later gesture undoes it. Looking at the player (expanding the circle) starts a still-pending soundtrack too. aero-music-test simulates the refusal (__scAllowPlay) and pins all three paths: one attempt anyway, the next tap starts it, an explicit pause stays. 28 checks. Version 0.7.1, SW v93.
This commit is contained in:
parent
a4c85ed77a
commit
1ad199fb56
5 changed files with 118 additions and 12 deletions
|
|
@ -27,7 +27,13 @@ const STUB = `(function(){
|
|||
getSounds: function (cb) { setTimeout(function () { cb(sounds); }, 10); },
|
||||
getCurrentSound: function (cb) { setTimeout(function () { cb(sounds[window.__scStub.current]); }, 0); },
|
||||
skip: function (index) { window.__scStub.skipped.push(index); window.__scStub.current = index; },
|
||||
play: function () { window.__scStub.plays += 1; emit("play"); },
|
||||
play: function () {
|
||||
window.__scStub.plays += 1;
|
||||
/* A browser that has not seen a gesture yet refuses the start: the
|
||||
app must retry from the next real one. */
|
||||
if (window.__scAllowPlay === false) return;
|
||||
emit("play");
|
||||
},
|
||||
pause: function () { window.__scStub.pauses += 1; emit("pause"); },
|
||||
setVolume: function (value) { window.__scStub.volume = value; }
|
||||
};
|
||||
|
|
@ -80,6 +86,7 @@ async function stubSoundCloud(page) {
|
|||
check("aero: a random track from the playlist is chosen", Number.isInteger(index) && index >= 0 && index < stub.sounds.length, String(index));
|
||||
check("aero: playback starts", stub.plays >= 1, String(stub.plays));
|
||||
check("aero: the embed points at the playlist", decodeURIComponent(stub.iframeSrc ?? "").includes("soundcloud.com/rustie-gamer/sets/frutiger-aero"));
|
||||
check("aero: the embed itself asks to autoplay", (stub.iframeSrc ?? "").includes("auto_play=true"));
|
||||
check("aero: background volume", stub.volume === 45, String(stub.volume));
|
||||
|
||||
await circle.click();
|
||||
|
|
@ -108,6 +115,62 @@ async function stubSoundCloud(page) {
|
|||
await context.close();
|
||||
}
|
||||
|
||||
/* 2b. a refused autoplay starts from the next gesture ----------------- */
|
||||
{
|
||||
const { context, page } = await makePage(browser, { width: 1280, height: 731 });
|
||||
await stubSoundCloud(page);
|
||||
await seed(page, { theme: "aero", decks: [] });
|
||||
/* Load with autoplay refused, the way a browser without activation does. */
|
||||
await page.addInitScript(() => {
|
||||
window.__scAllowPlay = false;
|
||||
});
|
||||
await page.goto(BASE, { waitUntil: "networkidle" });
|
||||
await page.waitForTimeout(1500);
|
||||
const first = await page.evaluate(() => window.__scStub.plays);
|
||||
check("blocked autoplay: one attempt is made anyway", first >= 1, String(first));
|
||||
check(
|
||||
"blocked autoplay: the circle shows nothing playing yet",
|
||||
(await page.getByRole("button", { name: "Frutiger Aero music" }).count()) === 1,
|
||||
);
|
||||
await page.getByRole("button", { name: "Frutiger Aero music" }).click();
|
||||
await page.waitForTimeout(300);
|
||||
check("blocked autoplay: play is offered while it waits", (await page.getByRole("button", { name: "Play the music" }).count()) === 1);
|
||||
await page.getByRole("button", { name: "Back to the music button" }).click();
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
/* The browser would now allow it: the next tap anywhere starts the music.
|
||||
(The retry throttle is 700ms, so give the previous attempt room.) */
|
||||
await page.waitForTimeout(900);
|
||||
await page.evaluate(() => {
|
||||
window.__scAllowPlay = true;
|
||||
});
|
||||
const before = await page.evaluate(() => window.__scStub.plays);
|
||||
await page.evaluate(() => {
|
||||
document.body.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true }));
|
||||
});
|
||||
await page.waitForTimeout(600);
|
||||
const after = await page.evaluate(() => window.__scStub.plays);
|
||||
check("blocked autoplay: the next tap starts the music", after > before, `${before} -> ${after}`);
|
||||
await page.getByRole("button", { name: "Frutiger Aero music" }).click();
|
||||
await page.waitForTimeout(400);
|
||||
check("after the gesture start the bar offers pause", (await page.getByRole("button", { name: "Pause the music" }).count()) === 1);
|
||||
|
||||
/* An explicit pause is respected: no gesture restarts it. */
|
||||
await page.getByRole("button", { name: "Pause the music" }).click();
|
||||
await page.waitForTimeout(300);
|
||||
const paused = await page.evaluate(() => window.__scStub.plays);
|
||||
await page.evaluate(() => {
|
||||
document.body.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true }));
|
||||
});
|
||||
await page.waitForTimeout(600);
|
||||
check(
|
||||
"an explicit pause is not undone by later taps",
|
||||
(await page.evaluate(() => window.__scStub.plays)) === paused,
|
||||
`${paused} -> ${await page.evaluate(() => window.__scStub.plays)}`,
|
||||
);
|
||||
await context.close();
|
||||
}
|
||||
|
||||
/* 3. picking Aero again is fresh consent ------------------------------ */
|
||||
{
|
||||
const { context, page } = await makePage(browser, { width: 1280, height: 731 });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue