Instance Method

beginTrimmingWithCompletionHandler:

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

Declaration

- (void)beginTrimmingWithCompletionHandler:(void (^)(AVPlayerViewTrimResult result))handler;

Parameters

handler

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

The argument passed in is AVPlayerViewTrimOKButton if the user chose the Trim button or AVPlayerViewTrimCancelButton if the user chose the Cancel button.

Discussion

An example implementation of the handler block is as follows:

- (IBAction)beginTrimming:(id)sender {
    [self.playerView beginTrimmingWithCompletionHandler:^(AVPlayerViewTrimResult result) {
        if (result == AVPlayerViewTrimOKButton) {
            // user selected Trim button (AVPlayerViewTrimOKButton)
        } else {
            // user selected Cancel button (AVPlayerViewTrimCancelButton)
        }
    }];
}

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.

canBeginTrimming

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

AVPlayerViewTrimResult

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