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

# tracks(withMediaType:)

Returns tracks that present media of a specified type.

## Declaration

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

## Parameters

- `mediaType`: The media type according to which the asset filters its tracks. For valid values see doc://com.apple.avfoundation/documentation/AVFoundation/AVMediaType.

## Return Value

Return Value An array of tracks of a specific media characteristic.

## Discussion

Discussion Apple discourages the use of this method in iOS 15, tvOS 15, and macOS 12 or later. Load tracks asynchronously using loadTracks(withMediaType:completionHandler:) instead. You may call this method without blocking the current thread after you’ve asynchronously loaded the tracks property.

## See Also

### Accessing tracks

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