---
title: "tracks(withMediaType:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avfragmentedmovie/tracks(withmediatype:)"
---

# tracks(withMediaType:)

Retrieves tracks in the movie that present media of the specified type.

## Declaration

```swift
func tracks(withMediaType mediaType: AVMediaType) -> [AVFragmentedMovieTrack]
```

## Parameters

- `mediaType`: The media type of the tracks to return.

## Return Value

Return Value An array of tracks, which is empty if there are no tracks with the media type.

## Discussion

Discussion Apple discourages using this method in iOS 15, tvOS 15, macOS 12, and watchOS 8 or later. Load tracks asynchronously using loadTracks(withMediaType:completionHandler:) instead.

## See Also

### Accessing tracks

- [tracks](avfoundation/avfragmentedmovie/tracks.md)
- [track(withTrackID:)](avfoundation/avfragmentedmovie/track(withtrackid:).md)
- [tracks(withMediaCharacteristic:)](avfoundation/avfragmentedmovie/tracks(withmediacharacteristic:).md)
