Add chapter skip and 10s seek controls to audio players
Build and Push Docker Image / build-and-push (push) Successful in 5m42s
Build and Push Docker Image / build-and-push (push) Successful in 5m42s
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5287b471d0
commit
b9f9b97cba
3 files changed
+59
No files matched your search
@@ -80,6 +80,22 @@ export function useAudio(readerBookAbbrev, readerChapter) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSeekAudio = (deltaSeconds) => {
|
||||
if (!audioRef.current) return;
|
||||
const el = audioRef.current;
|
||||
const duration = Number.isFinite(el.duration) ? el.duration : Infinity;
|
||||
el.currentTime = Math.min(Math.max(el.currentTime + deltaSeconds, 0), duration);
|
||||
};
|
||||
|
||||
const handleSkipBookChapter = () => {
|
||||
const nextChapter = audioStateRef.current.chapter + 1;
|
||||
if (nextChapter > audioStateRef.current.total) return;
|
||||
audioModeRef.current = 'book';
|
||||
playAudioChapter(audioBookRef.current, nextChapter, audioNarratorRef.current).catch(() =>
|
||||
setAudioState({ status: 'error', chapter: 0, total: 0 }),
|
||||
);
|
||||
};
|
||||
|
||||
const handlePlayReaderAudio = async () => {
|
||||
audioModeRef.current = 'reader';
|
||||
try {
|
||||
@@ -131,6 +147,8 @@ export function useAudio(readerBookAbbrev, readerChapter) {
|
||||
handlePlayBookAudio,
|
||||
handleStopBookAudio,
|
||||
handleToggleBookAudioPause,
|
||||
handleSkipBookChapter,
|
||||
handleSeekAudio,
|
||||
readerAudioState,
|
||||
handlePlayReaderAudio,
|
||||
handleToggleReaderAudioPause,
|
||||
|
||||
Reference in new issue
Block a user