Update read position while listening to audio

This commit is contained in:
Jackson Harper 2022-10-11 17:22:40 +08:00
parent f047775532
commit 25055598e3
2 changed files with 11 additions and 1 deletions

View file

@ -804,6 +804,17 @@ public class AudioController: NSObject, ObservableObject, AVAudioPlayerDelegate
}
}
}
if timeElapsed - 10 > lastReadUpdate {
let percentProgress = timeElapsed / duration
let anchorIndex = Int((player?.currentItem as? SpeechPlayerItem)?.speechItem.htmlIdx ?? "") ?? 0
if let itemID = itemAudioProperties?.itemID {
dataService.updateLinkReadingProgress(itemID: itemID, readingProgress: percentProgress, anchorIndex: anchorIndex)
}
lastReadUpdate = timeElapsed
}
}
func clearNowPlayingInfo() {

View file

@ -48,7 +48,6 @@ export function Article(props: ArticleProps): JSX.Element {
const debouncedSetReadingProgress = useMemo(
() =>
debounce((readingProgress: number) => {
console.log('setReadingProgress', readingProgress)
setReadingProgress(readingProgress)
}, 2000),
[]