<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioPlayerNode/scheduleSegment(_:startingFrame:frameCount:at:completionCallbackType:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioPlayerNode(im)scheduleSegment:startingFrame:frameCount:atTime:completionCallbackType:completionHandler:"
  },
  "title" : "scheduleSegment(_:startingFrame:frameCount:at:completionCallbackType:completionHandler:)"
}
-->

# scheduleSegment(_:startingFrame:frameCount:at:completionCallbackType:completionHandler:)

Schedules the playing of an audio file segment with a callback option you specify.

```
func scheduleSegment(_ file: AVAudioFile, startingFrame startFrame: AVAudioFramePosition, frameCount numberFrames: AVAudioFrameCount, at when: AVAudioTime?, completionCallbackType callbackType: AVAudioPlayerNodeCompletionCallbackType, completionHandler: (@Sendable (AVAudioPlayerNodeCompletionCallbackType) -> Void)? = nil)
```

## Parameters

`file`

The file to play.

`startFrame`

The starting frame position in the stream.

`numberFrames`

The number of frames to play.

`when`

The time the region plays.

`callbackType`

The option to specify when the system must call the completion handler.

`completionHandler`

The handler the system calls after the player schedules the segment for playback on the render thread, or the player stops.

## Discussion

---

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)