@@ -206,10 +206,9 @@ extension AbstractPlayer{
206
206
207
207
// Check if the video is already being looped
208
208
if playerLooper != nil {
209
- return // Already looped, no need to loop again
209
+ return
210
210
}
211
211
212
- // Initialize the player looper with the current item
213
212
playerLooper = AVPlayerLooper ( player: player, templateItem: currentItem)
214
213
}
215
214
@@ -264,15 +263,10 @@ extension AbstractPlayer{
264
263
/// and assigns it to the current AVPlayerItem. The video is paused during this process to ensure smooth application.
265
264
/// This method is not supported on Vision OS.
266
265
func applyVideoComposition( ) {
267
- guard let player = player, let currentItem = player. currentItem else { return }
268
-
266
+ guard let player = player else { return }
269
267
let allFilters = combineFilters ( filters, brightness, contrast)
270
- #if !os(visionOS)
271
- // Might be heavy operation need to explore
272
- let videoComposition = AVVideoComposition ( asset: currentItem. asset, applyingCIFiltersWithHandler: { request in
273
- handleVideoComposition ( request: request, filters: allFilters)
274
- } )
275
268
269
+ #if !os(visionOS)
276
270
// Optionally, check if the player is currently playing
277
271
let wasPlaying = player. rate != 0
278
272
@@ -281,8 +275,14 @@ extension AbstractPlayer{
281
275
player. pause ( )
282
276
}
283
277
284
- // Applying the video composition
285
- currentItem. videoComposition = videoComposition
278
+ player. items ( ) . forEach { item in
279
+
280
+ let videoComposition = AVVideoComposition ( asset: item. asset, applyingCIFiltersWithHandler: { request in
281
+ handleVideoComposition ( request: request, filters: allFilters)
282
+ } )
283
+
284
+ item. videoComposition = videoComposition
285
+ }
286
286
287
287
if wasPlaying{
288
288
player. play ( )
0 commit comments