Instance Method


Sets the player view’s controls panel into trimming mode.


func beginTrimming(completionHandler handler: ((AVPlayerViewTrimResult) -> Void)? = nil)



The block is executed when the user selects either the Trim or the Cancel button in the trimming UI.

The argument passed in is AVPlayerViewTrimResult.okButton if the user chose the Trim button or AVPlayerViewTrimResult.cancelButton if the user chose the Cancel button.


An example implementation of the handler block is as follows:

@IBAction func beginTrimming(_ sender: AnyObject) {
    playerView.beginTrimming { result in
        if result == .okButton {
            // user selected Trim button (AVPlayerViewTrimResult.okButton)...
        } else {
            // user selected Cancel button (AVPlayerViewTrimResult.cancelButton)...

This method blocks until the user selects either the Trim or the Cancel button.

See Also

Trimming Playback Content

Implementing Trimming (macOS)

Implement a QuickTime media-trimming experience in your macOS app.

var canBeginTrimming: Bool

A Boolean property that specifies if the current player view’s media can be trimmed.

enum AVPlayerViewTrimResult

Constants that specify what the user’s action was when trimming the media in a player view. See beginTrimming(completionHandler:) for more information.