fix: Bug fixes Scrub lag Chapter track last chapter Mini bar stays over music Resume ABS doesn't stop music
This commit is contained in:
1 parent
eb4d6fcbf9
commit
0d8b8b6f5d
3 files changed
+31
-6
No files matched your search
+18
-4
@@ -253,7 +253,12 @@ export async function absPlayItem(item) {
|
||||
|
||||
export function absTogglePlay() {
|
||||
const audio = _getAudio();
|
||||
S.absPlayer.playing ? audio.pause() : audio.play().catch(() => {});
|
||||
if (S.absPlayer.playing) {
|
||||
audio.pause();
|
||||
} else {
|
||||
if (S.audio && !S.audio.paused) S.audio.pause();
|
||||
audio.play().catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
export function absInterrupt() {
|
||||
@@ -261,6 +266,11 @@ export function absInterrupt() {
|
||||
_getAudio().pause(); // triggers the pause listener which calls _doSync()
|
||||
}
|
||||
|
||||
export function absOnMusicPause() {
|
||||
// When music pauses, re-evaluate mini bar visibility (ABS bar should reappear)
|
||||
if (S.absPlayer.item) _renderMiniBar();
|
||||
}
|
||||
|
||||
export function absSeek(globalTime) {
|
||||
const ap = S.absPlayer;
|
||||
globalTime = Math.max(0, Math.min(globalTime, ap.duration || Infinity));
|
||||
@@ -373,8 +383,11 @@ function _chapterWindow() {
|
||||
const ap = S.absPlayer;
|
||||
if (!_chapterTrackMode || ap.chapterIdx < 0 || !ap.chapters.length) return null;
|
||||
const ch = ap.chapters[ap.chapterIdx];
|
||||
if (!ch || ch.start == null) return null;
|
||||
const nextCh = ap.chapters[ap.chapterIdx + 1];
|
||||
return { start: ch.start ?? 0, end: nextCh?.start ?? ap.duration };
|
||||
const end = nextCh?.start ?? ch.end ?? ap.duration;
|
||||
if (end <= ch.start) return null;
|
||||
return { start: ch.start, end };
|
||||
}
|
||||
|
||||
// ─── PROGRESS SCRUB ───
|
||||
@@ -396,7 +409,8 @@ function _renderMiniBar() {
|
||||
const ap = S.absPlayer;
|
||||
const bar = document.getElementById('abs-mini-bar');
|
||||
if (!bar) return;
|
||||
if (!ap.item) { bar.classList.remove('visible'); return; }
|
||||
// Hide when no ABS item loaded, or when music is actively playing
|
||||
if (!ap.item || (S.audio && !S.audio.paused)) { bar.classList.remove('visible'); return; }
|
||||
bar.classList.add('visible');
|
||||
const meta = ap.item?.media?.metadata || {};
|
||||
const cover = absCoverUrl(ap.item?.id);
|
||||
@@ -452,7 +466,7 @@ function _renderPlayer() {
|
||||
function _renderProgress() {
|
||||
const ap = S.absPlayer;
|
||||
const win = _chapterWindow();
|
||||
const dispCur = win ? ap.currentTime - win.start : ap.currentTime;
|
||||
const dispCur = win ? Math.max(0, 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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user