---
title: "init(asset:automaticallyLoadedAssetKeys:)"
framework: avfoundation
role: symbol
role_heading: Initializer
path: "avfoundation/avplayeritem/init(asset:automaticallyloadedassetkeys:)-8x4"
---

# init(asset:automaticallyLoadedAssetKeys:)

Creates a player item with the specified asset and the asset keys to automatically load.

## Declaration

```swift
init(asset: AVAsset, automaticallyLoadedAssetKeys: [String]?)
```

## Parameters

- `asset`: An instance of doc://com.apple.avfoundation/documentation/AVFoundation/AVAsset.
- `automaticallyLoadedAssetKeys`: An array of strings, each representing a property defined by doc://com.apple.avfoundation/documentation/AVFoundation/AVAsset.

## Return Value

Return Value An initialized instance of AVPlayerItem.

## Discussion

Discussion The value of each key in automaticallyLoadedAssetKeys will automatically be loaded by the underlying AVAsset before the player item achieves the status AVPlayerItem.Status.readyToPlay; i.e. when the item is ready to play, the value returned by invoking the asset property’s statusOfValue(forKey:error:) method will be one of the terminal status values, either AVKeyValueStatus.loaded, AVKeyValueStatus.failed, or AVKeyValueStatus.cancelled.

## See Also

### Creating a player item

- [init(url:)](avfoundation/avplayeritem/init(url:)-1xrtk.md)
- [init(asset:)](avfoundation/avplayeritem/init(asset:)-87rjl.md)
- [init(asset:)](avfoundation/avplayeritem/init(asset:)-1nme9.md)
- [init(asset:automaticallyLoadedAssetKeys:)](avfoundation/avplayeritem/init(asset:automaticallyloadedassetkeys:)-5czjh.md)
- [init(asset:automaticallyLoadedAssetKeys:)](avfoundation/avplayeritem/init(asset:automaticallyloadedassetkeys:)-85hal.md)
