Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix volume related issues #1199

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion BookPlayer/Player/PlayerManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ final class PlayerManager: NSObject, PlayerManagerProtocol {

if currentTime >= currentItem.currentChapter.end || currentTime < currentItem.currentChapter.start,
let newChapter = currentItem.getChapter(at: currentTime),
newChapter != currentItem.currentChapter
newChapter != currentItem.currentChapter,
!currentItem.isBoundBook || newChapter.chapterOffset != 0
{
/// Avoid setting the same chapter, as it would publish an update event
currentItem.currentChapter = newChapter
Expand Down
5 changes: 4 additions & 1 deletion Shared/Services/PlaybackService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public final class PlaybackService: PlaybackServiceProtocol {

func getPlayableChapters(book: SimpleLibraryItem) throws -> [PlayableChapter] {
guard
let chapters = self.libraryService.getChapters(from: book.relativePath)
var chapters = self.libraryService.getChapters(from: book.relativePath)
else {
throw BookPlayerError.runtimeError(
String.localizedStringWithFormat(
Expand All @@ -209,6 +209,9 @@ public final class PlaybackService: PlaybackServiceProtocol {
)
}

/// Ignore chapters that don't have the duration set properly
chapters = chapters.filter { $0.duration > 0 }

guard !chapters.isEmpty else {
return [
PlayableChapter(
Expand Down