---
title: "beginTrimming(completionHandler:)"
framework: avkit
role: symbol
role_heading: Instance Method
path: "avkit/avplayerview/begintrimming(completionhandler:)"
---

# beginTrimming(completionHandler:)

Puts the player view into trimming mode.

## Declaration

```swift
func beginTrimming(completionHandler handler: (@Sendable (AVPlayerViewTrimResult) -> Void)? = nil)
```

```swift
func beginTrimming() async -> AVPlayerViewTrimResult
```

## Parameters

- `handler`: The callback the system invokes when the user selects the Trim or Cancel button in the trimming UI. The result passed to the closure indicates whether the user clicked the Trim or Cancel button.

## Mentioned in

Implementing Trimming in a macOS Player

## Discussion

Discussion 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 media

- [canBeginTrimming](avkit/avplayerview/canbegintrimming.md)
- [AVPlayerViewTrimResult](avkit/avplayerviewtrimresult.md)
