Skip to content
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
12 changes: 7 additions & 5 deletions Sources/Navigator/Audiobook/AudioNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct MediaPlaybackInfo {
}
}

public protocol AudioNavigatorDelegate: NavigatorDelegate {
@MainActor public protocol AudioNavigatorDelegate: NavigatorDelegate {
/// Called when the playback updates.
func navigator(_ navigator: AudioNavigator, playbackDidChange info: MediaPlaybackInfo)

Expand Down Expand Up @@ -108,7 +108,7 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo
}
}

public let publication: Publication
public nonisolated let publication: Publication
private let initialLocation: Locator?
private let config: Configuration

Expand Down Expand Up @@ -326,7 +326,7 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo

/// A deadlock can occur when loading HTTP assets and creating the playback info from the main thread.
/// To fix this, this is an asynchronous operation.
private func makePlaybackInfo(forTime time: Double? = nil, completion: @escaping (MediaPlaybackInfo) -> Void) {
private func makePlaybackInfo(forTime time: Double? = nil, completion: @escaping @MainActor (MediaPlaybackInfo) -> Void) {
DispatchQueue.global(qos: .userInteractive).async {
let info = MediaPlaybackInfo(
resourceIndex: self.resourceIndex,
Expand Down Expand Up @@ -389,7 +389,9 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo
}

self.lastLoadedTimeRanges = ranges
self.delegate?.navigator(self, loadedTimeRangesDidChange: ranges)
Task { @MainActor in
self.delegate?.navigator(self, loadedTimeRangesDidChange: ranges)
}
}

// MARK: - Navigator
Expand All @@ -411,7 +413,7 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo
player.replaceCurrentItem(with: AVPlayerItem(asset: asset))
resourceIndex = newResourceIndex
loadedTimeRangesTimer.fire()
delegate?.navigator(self, loadedTimeRangesDidChange: [])
await delegate?.navigator(self, loadedTimeRangesDidChange: [])
}

// Seeks to time
Expand Down
2 changes: 1 addition & 1 deletion Sources/Navigator/SelectableNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct Selection {
public let frame: CGRect?
}

public protocol SelectableNavigatorDelegate: NavigatorDelegate {
@MainActor public protocol SelectableNavigatorDelegate: NavigatorDelegate {
/// Returns whether the default edit menu (`UIMenuController`) should be displayed for the given `selection`.
///
/// To implement a custom selection pop-up, return false and display your own view using `selection.frame`.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Navigator/VisualNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public struct VisualNavigatorPresentation {
}
}

public protocol VisualNavigatorDelegate: NavigatorDelegate {
@MainActor public protocol VisualNavigatorDelegate: NavigatorDelegate {
/// Called when the navigator presentation changed, for example after
/// applying a new set of preferences.
func navigator(_ navigator: Navigator, presentationDidChange presentation: VisualNavigatorPresentation)
Expand Down
Loading