diff --git a/tests/ui/app.spec.ts b/tests/ui/app.spec.ts index 197f699..4403682 100644 --- a/tests/ui/app.spec.ts +++ b/tests/ui/app.spec.ts @@ -475,6 +475,38 @@ test('the Podcasts shelf shows the feeds with episodes, as their artwork, and op await expect(page.locator('#eps .ep', { hasText: 'First Episode' })).toBeVisible(); }); +test('Now Playing opens from the player bar with the artwork, show notes and Up Next (#475)', async ({ page }) => { + await page.evaluate(() => saveUpNext([])); + await page.locator('.feed', { hasText: 'Test Show' }).click(); + const first = page.locator('#eps .ep', { hasText: 'First Episode' }); + await first.hover(); + await first.locator('[data-a=queue]').click(); + const second = page.locator('#eps .ep', { hasText: 'Second Episode' }); + await second.hover(); + await second.locator('[data-a=play]').click(); + await expect(page.locator('#ptitle')).toHaveText('Second Episode'); + + const sheet = page.locator('#nowsheet'); + await page.locator('#pnow').click(); + await expect(sheet).toBeVisible(); + await expect(page.locator('#pnow')).toHaveAttribute('aria-expanded', 'true'); + await expect(sheet.locator('h2')).toHaveText('Second Episode'); + await expect(sheet.locator('.dbody')).toContainText('Notes for the second.'); + await expect(sheet.locator('#nowqueue .childrow')).toHaveText([/First Episode/]); + await page.keyboard.press('Escape'); + await expect(sheet).toBeHidden(); + // From the keyboard too, and the podcast's name opens its feed. + await page.locator('#pnow').focus(); + await page.keyboard.press('Enter'); + await sheet.locator('.nowshow').click(); + await expect(sheet).toBeHidden(); + await expect(page.locator('#eps .ep', { hasText: 'Second Episode' })).toBeVisible(); + + await page.locator('#pclose').click(); + await page.evaluate(() => saveUpNext([])); + await page.evaluate(() => api('/api/entries/test-show/ui-2/position', { method: 'POST', body: JSON.stringify({ secs: 0 }) })); +}); + test('a player nobody has played since it last saved does not save again', async ({ page }) => { // A tab left paused at 41:15 saved that as it reloaded, over the 32:48 another had reached, // and the episode dropped out of Currently Listening. The fixture audio does not decode, so diff --git a/web/CHANGELOG.md b/web/CHANGELOG.md index ce1d801..9f52c02 100644 --- a/web/CHANGELOG.md +++ b/web/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Now Playing: tap the player bar to see what is playing with its artwork large, its podcast (a tap opens it), its show notes and what follows in Up Next; Esc or the bar closes it (#475). - Podcasts: your podcasts as a shelf of their artwork, each with how many episodes are new; the search box narrows it, and a tap opens one (#474). - Up Next: line episodes up with the list button on a row or in the reader (`q`, or `Shift Q` to play one next), move them by their handles, and each plays when the one before it ends. The player has a Next button while something is lined up, and the lock screen's next-track button does the same (#473). - The page reads ipx's answers in protobuf, with a decoder of its own and no library, and in JSON from a server that has none; offline, a kept answer still shows what was read offline (#470). diff --git a/web/app.css b/web/app.css index 1e24887..8baf5cf 100644 --- a/web/app.css +++ b/web/app.css @@ -688,14 +688,34 @@ body.scan-this .fhead [data-a=scan] .i,body.scan-any .fhead [data-a=scanall] .i, /* Currently Listening: how far into each episode you are, as a rail along the foot of its row. The one in the player is marked as it is everywhere else, by the amber EQ bars, and its rail and time left move as it plays. The rest stay neutral, so that one is what stands out. */ -#listening .childrow{position:relative;overflow:hidden;gap:12px;padding:10px 10px 13px} -#listening .childrow .art{width:44px;height:44px;font-size:13px} -#listening .txt b{display:flex;align-items:center;gap:7px} -#listening .txt b span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} -#listening .txt small{display:flex;gap:12px;margin-top:3px;color:var(--faint);font-size:11.5px} -#listening .txt small .fd{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} -#listening .txt small .left{flex:none;color:var(--dim)} -#listening .childrow:not(.now) .eq{display:none} +#listening .childrow,#nowqueue .childrow{position:relative;overflow:hidden;gap:12px;padding:10px 10px 13px} +#listening .childrow .art,#nowqueue .childrow .art{width:44px;height:44px;font-size:13px} +#listening .txt b,#nowqueue .txt b{display:flex;align-items:center;gap:7px} +#listening .txt b span,#nowqueue .txt b span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +#listening .txt small,#nowqueue .txt small{display:flex;gap:12px;margin-top:3px;color:var(--faint);font-size:11.5px} +#listening .txt small .fd,#nowqueue .txt small .fd{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +#listening .txt small .left,#nowqueue .txt small .left{flex:none;color:var(--dim)} +#listening .childrow:not(.now) .eq,#nowqueue .childrow:not(.now) .eq{display:none} +/* Now Playing (#475): over the feeds and the list, above the player bar, which keeps the + controls. The artwork is the one large thing on the page. */ +#nowsheet{grid-row:1;grid-column:1/-1;z-index:30;overflow:auto;background:var(--bg); + padding:22px max(16px,calc((100% - 720px)/2)) 32px;position:relative} +#nowclose{position:absolute;top:14px;right:max(12px,calc((100% - 720px)/2 - 44px))} +.nowhead{display:grid;grid-template-columns:minmax(0,280px) minmax(0,1fr);gap:24px;align-items:end;margin:10px 0 26px} +.nowhead .nowart{width:100%;height:auto;aspect-ratio:1;border-radius:14px;font-size:56px} +.nowmeta{display:flex;flex-direction:column;gap:6px;min-width:0} +.nowmeta h2{margin:0;font-size:24px;line-height:1.2;text-wrap:balance} +.nowshow{align-self:flex-start;color:var(--accent);font-size:15px;font-weight:500;text-align:left} +.nowmeta small{color:var(--dim);font-size:12.5px;font-variant-numeric:tabular-nums} +#nowsheet h3{font-size:14px;font-weight:600;margin:22px 0 10px;color:var(--dim)} +#nowqueue{display:flex;flex-direction:column;gap:6px} +#pnow{cursor:pointer;border-radius:8px} +@media (max-width:820px){ + .nowhead{grid-template-columns:1fr;justify-items:center;text-align:center;gap:18px} + .nowhead .nowart{max-width:300px} + .nowmeta{align-items:center} + .nowshow{align-self:center;text-align:center} +} /* The Podcasts shelf (#474): the artwork is the podcast, as on a shelf of records, so nothing frames it: no card, no shadow, the name and its new episodes under it. */ .shelf{display:grid;grid-template-columns:repeat(auto-fill,minmax(112px,1fr));gap:20px 14px;padding:4px 2px 24px} @@ -708,14 +728,14 @@ body.scan-this .fhead [data-a=scan] .i,body.scan-any .fhead [data-a=scanall] .i, #listening .grip{width:22px;margin-left:-4px;color:var(--faint);cursor:grab;touch-action:none} #listening .grip svg{width:12px;height:12px} #listening .childrow.dragging{border-color:var(--accent);cursor:grabbing} -#listening .rail{position:absolute;left:0;right:0;bottom:0;height:3px;background:var(--raise)} -#listening .rail i{display:block;height:100%;width:0;background:var(--faint);transition:width .25s linear} -#listening .now{border-color:color-mix(in srgb,var(--accent2) 60%,var(--line))} -#listening .now .eq,#listening .now .left{color:var(--accent2)} -#listening .now .rail i{background:var(--accent2)} +#listening .rail,#nowqueue .rail{position:absolute;left:0;right:0;bottom:0;height:3px;background:var(--raise)} +#listening .rail i,#nowqueue .rail i{display:block;height:100%;width:0;background:var(--faint);transition:width .25s linear} +#listening .now,#nowqueue .now{border-color:color-mix(in srgb,var(--accent2) 60%,var(--line))} +#listening .now .eq,#nowqueue .now .eq,#listening .now .left,#nowqueue .now .left{color:var(--accent2)} +#listening .now .rail i,#nowqueue .now .rail i{background:var(--accent2)} /* Quiet buttons: a filled one on every row outshouted the row that is playing. */ -#listening [data-a=play]{color:var(--accent)} -#listening [data-a=remove]{color:var(--faint)} +#listening [data-a=play],#nowqueue [data-a=play]{color:var(--accent)} +#listening [data-a=remove],#nowqueue [data-a=remove]{color:var(--faint)} /* The Directory, laid out as Apple's is: a large title, then sections. Every page carries what kind of feed (.tabs, as the item filters are) in its title row. */ .dhead{margin-bottom:6px} diff --git a/web/build.mts b/web/build.mts index 172cb56..03d717b 100644 --- a/web/build.mts +++ b/web/build.mts @@ -29,7 +29,7 @@ const WEB_VERSION = JSON.parse(fs.readFileSync(path.join(here, '..', 'package.js // The files are one script, concatenated in this order, not modules: they share one top-level // scope, as the single inline script did, and code that runs at load needs what came before it. const PAGES: Record = { - 'index.html': { script: 'app.js', src: ['util', 'wire', 'theme', 'feeds', 'feedpage', 'items', 'player', 'upnext', 'dialogs', 'signals', 'gestures', 'offline', 'events', 'native'] }, + 'index.html': { script: 'app.js', src: ['util', 'wire', 'theme', 'feeds', 'feedpage', 'items', 'player', 'upnext', 'nowplaying', 'dialogs', 'signals', 'gestures', 'offline', 'events', 'native'] }, 'admin.html': { script: 'admin.js', src: ['util', 'wire', 'theme', 'admin'] }, 'login.html': { script: 'login.js', src: ['login'] }, }; diff --git a/web/index.html b/web/index.html index c77b936..98b2041 100644 --- a/web/index.html +++ b/web/index.html @@ -46,11 +46,12 @@
+
-
+ diff --git a/web/src/dialogs.ts b/web/src/dialogs.ts index c091e68..17bd00e 100644 --- a/web/src/dialogs.ts +++ b/web/src/dialogs.ts @@ -401,7 +401,7 @@ function paintListenRow(el: HTMLElement & {entry?: Entry}){ } /// Keeps the list in step with the player. Only a row that is, or was, the one in it changes. function syncListening(){ - for(const el of $$('#listening .childrow')) + for(const el of $$('#listening .childrow, #nowqueue .childrow')) if(el.entry&&(el.classList.contains('now')||inPlayer(el.entry))) paintListenRow(el); } diff --git a/web/src/native.ts b/web/src/native.ts index 5c791de..2d7a130 100644 --- a/web/src/native.ts +++ b/web/src/native.ts @@ -241,6 +241,7 @@ function installNativePlayback(){ fire(m.playing ? 'play' : 'pause'); renderEntries(); syncListening(); + drawNow(); } function stop(){ diff --git a/web/src/nowplaying.ts b/web/src/nowplaying.ts new file mode 100644 index 0000000..3a45276 --- /dev/null +++ b/web/src/nowplaying.ts @@ -0,0 +1,46 @@ +/* ---------------- Now Playing ---------------- */ +/// Now Playing (#475): what is playing, opened from the player bar. Its artwork large, the +/// podcast it is from, its show notes and what follows in Up Next. The bar stays below it with +/// the controls, so there is one set of them, not a second to keep in step. +const nowSheet=$('#nowsheet'); +const nowOpen=()=>!nowSheet.hidden; + +function openNow(){ + if(!player.guid) return; + nowSheet.hidden=false; + $('#pnow').setAttribute('aria-expanded','true'); + drawNow(); + $('#nowclose').focus(); +} +function closeNow(){ + if(!nowOpen()) return; + nowSheet.hidden=true; + $('#pnow').setAttribute('aria-expanded','false'); + $('#pnow').focus(); +} +/// Drawn again whenever what plays or what follows changes, while it is open. +function drawNow(){ + const e=player.entry; + if(!nowOpen()) return; + if(!e||!player.guid){ closeNow(); return; } + const name=entryName(e).text, show=feedName(e.feed_id); + nowSheet.innerHTML=` + +
+ ${artHTML(e.image||feedArt(e.feed_id),show,'nowart')} +
+

${esc(name)}

+ + ${[dateOf(e.published),e.duration?clock(e.duration):''].filter(Boolean).join(', ')} +
+
+ ${upNext.length?`

Up Next

`:''} +

Show notes

+
${textOf(e)}
`; + $('#nowclose').onclick=closeNow; + $('.nowshow',nowSheet).onclick=()=>{ closeNow(); selectFeed(e.feed_id); }; + const q=$('#nowqueue'); + for(const x of upNext) q?.appendChild(listenRow(x,'Remove from Up Next',()=>saveUpNext(upNext.filter(y=>entryKey(y)!==entryKey(x))))); +} +$('#pnow').onclick=()=>nowOpen()?closeNow():openNow(); +$('#pnow').onkeydown=(ev: KeyboardEvent)=>{ if(ev.key==='Enter'||ev.key===' '){ ev.preventDefault(); $('#pnow').click(); } }; diff --git a/web/src/player.ts b/web/src/player.ts index 5fdedc4..2736954 100644 --- a/web/src/player.ts +++ b/web/src/player.ts @@ -87,6 +87,7 @@ function play(e: Entry,enc=e.enclosures.find(isPlayable)){ paintDead(); startedPlaying(e); hostNext(); + drawNow(); } const go=()=>audio.play().catch(playFailed); if(wait) wait.then(go,playFailed); else go(); @@ -279,7 +280,7 @@ async function switchVersion(){ if(was) (wait||Promise.resolve()).then(()=>audio.play()).catch(()=>{}); return true; } -$('#pclose').onclick=()=>{if(sleepAt)sleepIn(0);savePos();audio.pause();dropHls();audio.removeAttribute('src');player.guid=null;$('#player').classList.remove('on');document.body.classList.remove('has-video');renderEntries(); +$('#pclose').onclick=()=>{closeNow();if(sleepAt)sleepIn(0);savePos();audio.pause();dropHls();audio.removeAttribute('src');player.guid=null;$('#player').classList.remove('on');document.body.classList.remove('has-video');renderEntries(); // Called here, not left to the pause event: closing a player already paused fires none. syncListening()}; (function restore(){ @@ -291,7 +292,7 @@ $('#pclose').onclick=()=>{if(sleepAt)sleepIn(0);savePos();aud document.addEventListener('keydown',ev=>{ // Escape leaves a dialog even from inside one of its boxes. It used to sit below the check // that follows, so Add feed, which opens with the cursor in its URL box, ignored it. - if(ev.key==='Escape'){closeModal();nav(false);return} + if(ev.key==='Escape'){closeModal();nav(false);closeNow();return} // The rest are single keys that would otherwise eat what you type. if(/^(INPUT|TEXTAREA|SELECT)$/.test((ev.target as Element).tagName)) return; if(ev.key===' '&&player.guid){ev.preventDefault();audio.paused?audio.play():audio.pause()} diff --git a/web/src/upnext.ts b/web/src/upnext.ts index 5566f37..4b864ca 100644 --- a/web/src/upnext.ts +++ b/web/src/upnext.ts @@ -25,6 +25,7 @@ async function saveUpNext(list: Entry[]){ function upNextChanged(){ renderFeeds(); if(S.feed===':upnext') drawUpNext(); + drawNow(); // The rows' and the reader's buttons say whether each is in it. for(const b of $$('[data-a=queue]')) paintQueueButton(b); hostNext();