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{
102
102
timePublisher: timePublisher,
103
103
eventPublisher: eventPublisher
104
104
)
105
- . onDisappear {
106
- //player?.onDeinit()
107
- //player = nil
108
- }
109
105
. onReceive ( timePublisher. receive ( on: DispatchQueue . main) , perform: { time in
110
106
currentTime = time
111
107
} )
Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ extension PlayerEvent: CustomStringConvertible {
112
112
return " Status: ReadyToPlay "
113
113
case . failed:
114
114
return " Status: FailedToLoad "
115
+ @unknown default :
116
+ return " Unknown status "
115
117
}
116
118
case . duration( let value) :
117
119
let roundedString = String ( format: " %.0f " , value. seconds)
Original file line number Diff line number Diff line change 7
7
8
8
import AVFoundation
9
9
#if canImport(CoreImage)
10
- import CoreImage
10
+ @ preconcurrency import CoreImage
11
11
import AVKit
12
12
#endif
13
13
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ internal extension ExtPlayerProtocol {
181
181
currentSettings = settings
182
182
183
183
guard let newItem = createPlayerItem ( with: settings) else {
184
- onError ( . sourceNotFound ( settings. name) )
184
+ itemNotFound ( with : settings. name)
185
185
return
186
186
}
187
187
@@ -203,6 +203,14 @@ internal extension ExtPlayerProtocol {
203
203
delegate? . didReceiveError ( error)
204
204
}
205
205
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
+
206
214
/// Observes the status of an AVPlayerItem and notifies the delegate when the status changes.
207
215
/// - Parameter item: The AVPlayerItem whose status should be observed.
208
216
private func observeItemStatus( _ item: AVPlayerItem ) {
@@ -224,6 +232,10 @@ internal extension ExtPlayerProtocol {
224
232
Task { @MainActor in
225
233
self ? . onError ( . failedToLoad)
226
234
}
235
+ @unknown default :
236
+ Task { @MainActor in
237
+ self ? . onError ( . failedToLoad)
238
+ }
227
239
}
228
240
}
229
241
}
You can’t perform that action at this time.
0 commit comments