---
title: "init(primaryItem:identifier:time:templateItems:restrictions:resumptionOffset:playoutLimit:userDefinedAttributes:)"
framework: avfoundation
role: symbol
role_heading: Initializer
path: "avfoundation/avplayerinterstitialevent/init(primaryitem:identifier:time:templateitems:restrictions:resumptionoffset:playoutlimit:userdefinedattributes:)"
---

# init(primaryItem:identifier:time:templateItems:restrictions:resumptionOffset:playoutLimit:userDefinedAttributes:)

Creates an interstitial event, with user-defined attributes, for the specified time.

## Declaration

```swift
convenience init(primaryItem: AVPlayerItem, identifier: String?, time: CMTime, templateItems: [AVPlayerItem], restrictions: AVPlayerInterstitialEvent.Restrictions = [], resumptionOffset: CMTime = .indefinite, playoutLimit: CMTime = .invalid, userDefinedAttributes: [String : Any] = [:])
```

## Parameters

- `primaryItem`: The player item that represents the primary content. The item must contain an doc://com.apple.avfoundation/documentation/AVFoundation/AVAsset that provides intrinsic mappings from its timeline to real-time dates.
- `identifier`: An external identifier for the event.
- `time`: The time in the primary item’s timeline for playback of interstitial content to begin.
- `templateItems`: An array of player item configurations to use as templates for player items that play interstitial content.
- `restrictions`: Restrictions on access to playback controls during the event.
- `resumptionOffset`: The time offset for resuming playback of the primary content after interstitial content finishes. You can specify a definite time, or specify doc://com.apple.documentation/documentation/CoreMedia/CMTime/indefinite to indicate that the effective resumption time offset needs to align with time elapsed during interstitial playback.
- `playoutLimit`: The time offset from the beginning of the interstitial when interstitial playback needs to end, if interstitial assets are longer. Pass a positive numeric value, or doc://com.apple.documentation/documentation/CoreMedia/CMTime/invalid to indicate no play out limit.
- `userDefinedAttributes`: Custom attributes to add to the event.

## See Also

### Creating an event

- [init(primaryItem:time:)](avfoundation/avplayerinterstitialevent/init(primaryitem:time:).md)
- [init(primaryItem:date:)](avfoundation/avplayerinterstitialevent/init(primaryitem:date:).md)
- [init(primaryItem:identifier:date:templateItems:restrictions:resumptionOffset:playoutLimit:userDefinedAttributes:)](avfoundation/avplayerinterstitialevent/init(primaryitem:identifier:date:templateitems:restrictions:resumptionoffset:playoutlimit:userdefinedattributes:).md)
