Skip to content

Commit

Permalink
Merge pull request #1199 from TortugaPower/fix-playback
Browse files Browse the repository at this point in the history
Fix volume related issues
  • Loading branch information
GianniCarlo authored Oct 7, 2024
2 parents fea7739 + f9c17d9 commit fac3e62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit fac3e62

Please sign in to comment.