@@ -50,7 +50,7 @@ public struct MediaPlaybackInfo {
50
50
}
51
51
}
52
52
53
- public protocol AudioNavigatorDelegate : NavigatorDelegate {
53
+ @ MainActor public protocol AudioNavigatorDelegate : NavigatorDelegate {
54
54
/// Called when the playback updates.
55
55
func navigator( _ navigator: AudioNavigator , playbackDidChange info: MediaPlaybackInfo )
56
56
@@ -108,7 +108,7 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo
108
108
}
109
109
}
110
110
111
- public let publication : Publication
111
+ public nonisolated let publication : Publication
112
112
private let initialLocation : Locator ?
113
113
private let config : Configuration
114
114
@@ -326,7 +326,7 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo
326
326
327
327
/// A deadlock can occur when loading HTTP assets and creating the playback info from the main thread.
328
328
/// To fix this, this is an asynchronous operation.
329
- private func makePlaybackInfo( forTime time: Double ? = nil , completion: @escaping ( MediaPlaybackInfo ) -> Void ) {
329
+ private func makePlaybackInfo( forTime time: Double ? = nil , completion: @escaping @ MainActor ( MediaPlaybackInfo ) -> Void ) {
330
330
DispatchQueue . global ( qos: . userInteractive) . async {
331
331
let info = MediaPlaybackInfo (
332
332
resourceIndex: self . resourceIndex,
@@ -389,7 +389,9 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo
389
389
}
390
390
391
391
self . lastLoadedTimeRanges = ranges
392
- self . delegate? . navigator ( self , loadedTimeRangesDidChange: ranges)
392
+ Task { @MainActor in
393
+ self . delegate? . navigator ( self , loadedTimeRangesDidChange: ranges)
394
+ }
393
395
}
394
396
395
397
// MARK: - Navigator
@@ -411,7 +413,7 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo
411
413
player. replaceCurrentItem ( with: AVPlayerItem ( asset: asset) )
412
414
resourceIndex = newResourceIndex
413
415
loadedTimeRangesTimer. fire ( )
414
- delegate? . navigator ( self , loadedTimeRangesDidChange: [ ] )
416
+ await delegate? . navigator ( self , loadedTimeRangesDidChange: [ ] )
415
417
}
416
418
417
419
// Seeks to time
0 commit comments