Now Playing: a full view of what is playing (#475)

Tapping the player bar, or Enter on it, opens a sheet over the feeds and the
list: the episode's artwork large, its podcast, its show notes and Up Next.
The bar stays below it with the controls, so there is one set of them rather
than a second kept in step. Chapters are left for #477: nothing reads them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 14:40:02 +00:00
parent 1fb1edd6b0
commit 2faca684da
10 changed files with 123 additions and 20 deletions

View File

@@ -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 $$<HTMLElement & {entry?: Entry}>('#listening .childrow'))
for(const el of $$<HTMLElement & {entry?: Entry}>('#listening .childrow, #nowqueue .childrow'))
if(el.entry&&(el.classList.contains('now')||inPlayer(el.entry))) paintListenRow(el);
}

View File

@@ -241,6 +241,7 @@ function installNativePlayback(){
fire(m.playing ? 'play' : 'pause');
renderEntries();
syncListening();
drawNow();
}
function stop(){

46
web/src/nowplaying.ts Normal file
View File

@@ -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();
$<HTMLButtonElement>('#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=`
<button class="iconbtn" id="nowclose" title="Close Now Playing (Esc)" aria-label="Close Now Playing">${ICON.close}</button>
<div class="nowhead">
${artHTML(e.image||feedArt(e.feed_id),show,'nowart')}
<div class="nowmeta">
<h2>${esc(name)}</h2>
<button type="button" class="nowshow">${esc(show)}</button>
<small>${[dateOf(e.published),e.duration?clock(e.duration):''].filter(Boolean).join(', ')}</small>
</div>
</div>
${upNext.length?`<h3>Up Next</h3><div class="childlist" id="nowqueue"></div>`:''}
<h3>Show notes</h3>
<div class="dbody">${textOf(e)}</div>`;
$<HTMLButtonElement>('#nowclose').onclick=closeNow;
$<HTMLButtonElement>('.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(); } };

View File

@@ -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;
}
$<HTMLButtonElement>('#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();
$<HTMLButtonElement>('#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 @@ $<HTMLButtonElement>('#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()}

View File

@@ -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 $$<HTMLButtonElement>('[data-a=queue]')) paintQueueButton(b);
hostNext();