<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVAssetWritingPlanner/plan(_:segmentHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "s:So21AVAssetWritingPlannerC12AVFoundationE4plan_14segmentHandlerySo0A9TrackPlanC_AbCE13SegmentResultOSo09AVPlannedjB7RequestCYaYbKctF"
  },
  "title" : "plan(_:segmentHandler:)"
}
-->

# plan(_:segmentHandler:)

Adds a track plan with manual segment completion control.

```
func plan(_ trackPlan: AVAssetTrackPlan, segmentHandler: @escaping @Sendable (AVPlannedSegmentWritingRequest) async throws -> AVAssetWritingPlanner.SegmentResult)
```

## Parameters

`trackPlan`

The track plan contains information about the track and boundaries of all the segments.

`segmentHandler`

Handler that returns a [`AVAssetWritingPlanner.SegmentResult`](/documentation/AVFoundation/AVAssetWritingPlanner/SegmentResult) for manual control.

## Discussion

This variant provides fine-grained control over segment completion, allowing you to
return a [`AVAssetWritingPlanner.SegmentResult`](/documentation/AVFoundation/AVAssetWritingPlanner/SegmentResult) that explicitly controls how the segment completes.

## Topics

### See Also

[`enum SegmentResult`](/documentation/AVFoundation/AVAssetWritingPlanner/SegmentResult)

Result type for manual segment completion control.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)