---
title: "init(targetEntity:audioResourceName:gain:useControlledPlayback:)"
framework: realitykit
role: symbol
role_heading: Initializer
path: "realitykit/playaudioaction/init(targetentity:audioresourcename:gain:usecontrolledplayback:)"
---

# init(targetEntity:audioResourceName:gain:useControlledPlayback:)

Creates a new play audio action.

## Declaration

```swift
init(targetEntity: ActionEntityResolution = .sourceEntity, audioResourceName: String, gain: Audio.Decibel = 0, useControlledPlayback: Bool = true)
```

## Parameters

- `targetEntity`: The entity to play the audio.
- `audioResourceName`: The name of the audio stored in audio library component of the target entity to start playing.
- `gain`: The individual gain in decibels of the audio.
- `useControlledPlayback`: Determines whether this action has control over the playback of the audio.
