fix: CROS fix, Mini Bar fix switches Audiobook and Music Player, Chapter Track mode added, Delted Playlist mode from Audiobooks
This commit is contained in:
1 parent
8f126562e7
commit
eb4d6fcbf9
5 files changed
+61
-55
No files matched your search
+31
-32
@@ -185,10 +185,6 @@ function _updateChapter() {
|
||||
ap.chapterIdx = idx;
|
||||
_renderChapterName();
|
||||
_renderChapterList();
|
||||
if (_playlistMode) {
|
||||
const cl = document.getElementById('abs-chapter-list');
|
||||
setTimeout(() => cl?.querySelector('.abs-ch-item.active')?.scrollIntoView({ block: 'nearest', behavior: 'smooth' }), 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +340,6 @@ export function absClosePlayer() {
|
||||
}
|
||||
|
||||
export function absToggleChapters() {
|
||||
if (_playlistMode) return;
|
||||
document.getElementById('abs-chapter-list')?.classList.toggle('open');
|
||||
_renderChapterList();
|
||||
}
|
||||
@@ -364,28 +359,22 @@ export function absSeekToChapter(idx) {
|
||||
if (ch) absSeek(ch.start);
|
||||
}
|
||||
|
||||
// ─── PLAYLIST MODE ───
|
||||
let _playlistMode = localStorage.getItem('ns_abs_pl_mode') === '1';
|
||||
// ─── CHAPTER TRACK MODE ───
|
||||
let _chapterTrackMode = localStorage.getItem('ns_abs_chtrack') === '1';
|
||||
|
||||
export function absTogglePlaylistMode() {
|
||||
_playlistMode = !_playlistMode;
|
||||
localStorage.setItem('ns_abs_pl_mode', _playlistMode ? '1' : '0');
|
||||
_applyPlaylistMode();
|
||||
export function absToggleChapterTrack() {
|
||||
_chapterTrackMode = !_chapterTrackMode;
|
||||
localStorage.setItem('ns_abs_chtrack', _chapterTrackMode ? '1' : '0');
|
||||
document.getElementById('abs-chtrack-btn')?.classList.toggle('active', _chapterTrackMode);
|
||||
_renderProgress();
|
||||
}
|
||||
|
||||
function _applyPlaylistMode() {
|
||||
const overlay = document.getElementById('abs-player');
|
||||
overlay?.classList.toggle('playlist-mode', _playlistMode);
|
||||
document.getElementById('abs-playlist-btn')?.classList.toggle('active', _playlistMode);
|
||||
const cl = document.getElementById('abs-chapter-list');
|
||||
if (!cl) return;
|
||||
if (_playlistMode) {
|
||||
cl.classList.add('open');
|
||||
_renderChapterList();
|
||||
setTimeout(() => cl.querySelector('.abs-ch-item.active')?.scrollIntoView({ block: 'nearest', behavior: 'smooth' }), 50);
|
||||
} else {
|
||||
cl.classList.remove('open');
|
||||
}
|
||||
function _chapterWindow() {
|
||||
const ap = S.absPlayer;
|
||||
if (!_chapterTrackMode || ap.chapterIdx < 0 || !ap.chapters.length) return null;
|
||||
const ch = ap.chapters[ap.chapterIdx];
|
||||
const nextCh = ap.chapters[ap.chapterIdx + 1];
|
||||
return { start: ch.start ?? 0, end: nextCh?.start ?? ap.duration };
|
||||
}
|
||||
|
||||
// ─── PROGRESS SCRUB ───
|
||||
@@ -397,8 +386,9 @@ function _scrub(e) {
|
||||
const bar = document.getElementById('abs-prog-bar');
|
||||
if (!bar) return;
|
||||
const rect = bar.getBoundingClientRect();
|
||||
const x = (e.touches?.[0]?.clientX ?? e.clientX) - rect.left;
|
||||
absSeek((Math.max(0, Math.min(1, x / rect.width))) * S.absPlayer.duration);
|
||||
const pct = Math.max(0, Math.min(1, ((e.touches?.[0]?.clientX ?? e.clientX) - rect.left) / rect.width));
|
||||
const win = _chapterWindow();
|
||||
absSeek(win ? win.start + pct * (win.end - win.start) : pct * S.absPlayer.duration);
|
||||
}
|
||||
|
||||
// ─── RENDER HELPERS ───
|
||||
@@ -456,20 +446,29 @@ function _renderPlayer() {
|
||||
_renderChapterName();
|
||||
_renderSleepBtn();
|
||||
_renderMiniBar();
|
||||
_applyPlaylistMode();
|
||||
document.getElementById('abs-chtrack-btn')?.classList.toggle('active', _chapterTrackMode);
|
||||
}
|
||||
|
||||
function _renderProgress() {
|
||||
const ap = S.absPlayer;
|
||||
const pct = ap.duration > 0 ? (ap.currentTime / ap.duration) * 100 : 0;
|
||||
const win = _chapterWindow();
|
||||
const dispCur = win ? ap.currentTime - win.start : ap.currentTime;
|
||||
const dispDur = win ? win.end - win.start : ap.duration;
|
||||
const pct = dispDur > 0 ? Math.min(100, (dispCur / dispDur) * 100) : 0;
|
||||
|
||||
const fill = document.getElementById('abs-prog-fill');
|
||||
const thumb = document.getElementById('abs-prog-thumb');
|
||||
if (fill) fill.style.width = `${Math.min(100, pct)}%`;
|
||||
if (thumb) thumb.style.left = `${Math.min(100, pct)}%`;
|
||||
if (fill) fill.style.width = `${pct}%`;
|
||||
if (thumb) thumb.style.left = `${pct}%`;
|
||||
const cur = document.getElementById('abs-time-cur');
|
||||
const rem = document.getElementById('abs-time-rem');
|
||||
if (cur) cur.textContent = _fmt(ap.currentTime);
|
||||
if (rem) rem.textContent = `-${_fmt(ap.duration - ap.currentTime)}`;
|
||||
if (cur) cur.textContent = _fmt(dispCur);
|
||||
if (rem) rem.textContent = `-${_fmt(dispDur - dispCur)}`;
|
||||
|
||||
// mini bar strip always shows full-book progress
|
||||
const miniPct = ap.duration > 0 ? Math.min(100, (ap.currentTime / ap.duration) * 100) : 0;
|
||||
const miniFill = document.getElementById('abs-mini-prog-fill');
|
||||
if (miniFill) miniFill.style.width = `${miniPct}%`;
|
||||
}
|
||||
|
||||
function _renderControls() {
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import {
|
||||
absSetSpeed, absSleepIn, absOpenPlayer, absClosePlayer, absToggleChapters,
|
||||
absToggleSpeedPicker, absToggleSleepPicker, absSeekToChapter, absProgDown, absProgMove,
|
||||
absProgUp, loadAbsBooks, absOpenBook, loadAbsBookDetail, absPlayChapter,
|
||||
absLoadSettingsLibraries, absTogglePlaylistMode, absInterrupt,
|
||||
absLoadSettingsLibraries, absToggleChapterTrack, absInterrupt,
|
||||
} from './abs.js';
|
||||
import {
|
||||
openNowPlaying, closeNowPlaying, switchNpTab, npGoArtist, npGoAlbum,
|
||||
@@ -271,7 +271,7 @@ Object.assign(window, {
|
||||
absSetSpeed, absSleepIn, absOpenPlayer, absClosePlayer, absToggleChapters,
|
||||
absToggleSpeedPicker, absToggleSleepPicker, absSeekToChapter,
|
||||
absProgDown, absProgMove, absProgUp,
|
||||
absOpenBook, absPlayChapter, absConnectSettings, absSetLibrary, absDisconnect, absTogglePlaylistMode,
|
||||
absOpenBook, absPlayChapter, absConnectSettings, absSetLibrary, absDisconnect, absToggleChapterTrack,
|
||||
absOnSearch: (val) => {
|
||||
clearTimeout(window._absSearchTimer);
|
||||
window._absSearchTimer = setTimeout(() => {
|
||||
|
||||
Reference in new issue
Block a user