File tree Expand file tree Collapse file tree 4 files changed +16
-6
lines changed
Sources/swiftui-loop-videoplayer Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -102,10 +102,6 @@ public struct ExtVideoPlayer: View{
102102 timePublisher: timePublisher,
103103 eventPublisher: eventPublisher
104104 )
105- . onDisappear {
106- //player?.onDeinit()
107- //player = nil
108- }
109105 . onReceive ( timePublisher. receive ( on: DispatchQueue . main) , perform: { time in
110106 currentTime = time
111107 } )
Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ extension PlayerEvent: CustomStringConvertible {
112112 return " Status: ReadyToPlay "
113113 case . failed:
114114 return " Status: FailedToLoad "
115+ @unknown default :
116+ return " Unknown status "
115117 }
116118 case . duration( let value) :
117119 let roundedString = String ( format: " %.0f " , value. seconds)
Original file line number Diff line number Diff line change 77
88import AVFoundation
99#if canImport(CoreImage)
10- import CoreImage
10+ @ preconcurrency import CoreImage
1111import AVKit
1212#endif
1313
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ internal extension ExtPlayerProtocol {
181181 currentSettings = settings
182182
183183 guard let newItem = createPlayerItem ( with: settings) else {
184- onError ( . sourceNotFound ( settings. name) )
184+ itemNotFound ( with : settings. name)
185185 return
186186 }
187187
@@ -203,6 +203,14 @@ internal extension ExtPlayerProtocol {
203203 delegate? . didReceiveError ( error)
204204 }
205205
206+ /// Emit the error "Item not found" with delay
207+ /// - Parameter name: resource name
208+ func itemNotFound( with name: String ) {
209+ Task { @MainActor [ weak self] in
210+ self ? . onError ( . sourceNotFound( name) )
211+ }
212+ }
213+
206214 /// Observes the status of an AVPlayerItem and notifies the delegate when the status changes.
207215 /// - Parameter item: The AVPlayerItem whose status should be observed.
208216 private func observeItemStatus( _ item: AVPlayerItem ) {
@@ -224,6 +232,10 @@ internal extension ExtPlayerProtocol {
224232 Task { @MainActor in
225233 self ? . onError ( . failedToLoad)
226234 }
235+ @unknown default :
236+ Task { @MainActor in
237+ self ? . onError ( . failedToLoad)
238+ }
227239 }
228240 }
229241 }
You can’t perform that action at this time.
0 commit comments