Add persistent mini now-playing bar

Fixed bar at bottom of window when video is playing. Shows title,
channel, progress, play/pause toggle. Click to restore player view.

Files:
- frontend/index.html: mini-bar markup
- frontend/app.js: showMiniBar/hideMiniBar/updateMiniBar, wiring
- frontend/styles.css: .mini-bar, .mini-bar-inner, .mini-progress styles
This commit is contained in:
Jonathan Sykes
2026-06-14 15:18:57 +08:00
parent 4376cd9e88
commit c1855a1a91
7 changed files with 119 additions and 1 deletions

View File

@@ -263,6 +263,7 @@ const Player = {
els.npChannel.textContent = current.meta.channel || '';
updateNowPlayingActions();
markPlayingCard();
showMiniBar();
// Restore saved playback position
const id = current.meta.id;
if (data.resumePositions[id] && data.resumePositions[id] > 1) {
@@ -526,6 +527,7 @@ function wirePlayerEvents() {
function updatePlayBtn() {
els.playBtn.textContent = Player.master.paused ? '▶' : '⏸';
$('miniPlayBtn').textContent = Player.master.paused ? '▶' : '⏸';
}
// Reflect cache state on the now-playing Save button.
function updateNowPlayingActions() {
@@ -555,6 +557,30 @@ function updateProgress() {
els.curTime.textContent = fmtTime(cur);
els.durTime.textContent = fmtTime(dur);
if (dur) els.seek.value = String((cur / dur) * 1000);
updateMiniBar();
}
// ============================================================================
// Mini now-playing bar
// ============================================================================
function showMiniBar() {
if (!current || !current.meta) return;
$('miniTitle').textContent = current.meta.title;
$('miniChannel').textContent = current.meta.channel || '';
$('miniBar').classList.remove('hidden');
updateMiniBar();
}
function updateMiniBar() {
if (!current || !current.meta) return;
const cur = Player.master.currentTime || 0;
const dur = Player.master.duration || 0;
$('miniTime').textContent = fmtTime(cur);
if (dur > 0) {
$('miniProgressFill').style.width = Math.min(100, (cur / dur) * 100) + '%';
}
}
function hideMiniBar() {
$('miniBar').classList.add('hidden');
}
// ============================================================================
@@ -1236,6 +1262,15 @@ function wireUI() {
$('modal').addEventListener('click', (e) => { if (e.target.id === 'modal') closeModal(); });
// Mini now-playing bar
$('miniPlayBtn').addEventListener('click', (e) => { e.stopPropagation(); Player.toggle(); });
$('miniBar').addEventListener('click', () => {
hideMiniBar();
// Scroll the player into view if needed
els.playerPane.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
});
$('miniCloseBtn').addEventListener('click', (e) => { e.stopPropagation(); hideMiniBar(); });
// Drag-to-reorder: prevent default on cards container
els.cards.addEventListener('dragover', (e) => {
if (view.type === 'playlist') e.preventDefault();