Skip to content

Commit 9f2e631

Browse files
committed
update
1 parent 6790273 commit 9f2e631

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Sources/swiftui-loop-videoplayer/ExtVideoPlayer.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff 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
})

Sources/swiftui-loop-videoplayer/enum/PlayerEvent.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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)

Sources/swiftui-loop-videoplayer/protocol/player/AbstractPlayer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import AVFoundation
99
#if canImport(CoreImage)
10-
import CoreImage
10+
@preconcurrency import CoreImage
1111
import AVKit
1212
#endif
1313

Sources/swiftui-loop-videoplayer/protocol/player/ExtPlayerProtocol.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)