Technical Q&A QA1966
Rendering the currently visible frame of a paused AVPlayer that has a custom video compositor
Q:
How can I re-render the currently visible frame of a paused AVPlayer
that has a custom video compositor? I would like to update values that affect the rendered video while it is paused, and have those changes reflected in the currently visible frame.
A: To re-render a frame, you must set a new instance of AVVideoComposition
to the player's current player item as shown in Listing 1.
Listing 1 Setting the video composition for a paused player to re-render the currently visible frame.
let asset:AVAsset = <#An asset#> |
let playerItem:AVPlayerItem = <#A player's current player item#> |
var applyComposition: ((AVAsynchronousCIImageFilteringRequest) -> Void)? = nil |
applyComposition = { request in |
... |
} |
let composition = AVVideoComposition(asset: asset, |
applyingCIFiltersWithHandler: applyComposition) |
playerItem.videoComposition = composition // Set the player item video composition. |
Document Revision History
Date | Notes |
---|---|
2017-12-04 | New document that shows how to re-render the currently visible frame of a paused AVPlayer that has a custom video compositor |
Copyright © 2017 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2017-12-04