---
title: "insertMediaTimeRange(_:into:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avmutablemovietrack/insertmediatimerange(_:into:)"
---

# insertMediaTimeRange(_:into:)

Inserts a reference to a media time range into a track.

## Declaration

```swift
func insertMediaTimeRange(_ mediaTimeRange: CMTimeRange, into trackTimeRange: CMTimeRange) -> Bool
```

## Parameters

- `mediaTimeRange`: The presentation time range of the media to be inserted.
- `trackTimeRange`: The time range of the track into which the media is to be inserted.

## Return Value

Return Value A Boolean value that indicates whether the insertion was successful.

## Discussion

Discussion Use this method after appending samples or sample references to a track’s media. To specify that the media time range be played at its natural rate, pass mediaTimeRange.duration == trackTimeRange.duration; otherwise, the ratio between these is used to determine the playback rate. Pass invalid for trackTimeRange.start to indicate that the segment should be appended to the end of the track.

## See Also

### Appending sample data

- [append(_:)](avfoundation/avmutablemovietrack/append(_:).md)
- [append(_:decodeTime:presentationTime:)](avfoundation/avmutablemovietrack/append(_:decodetime:presentationtime:).md)
