---
title: "playAudio(_:)"
framework: realitykit
role: symbol
role_heading: Type Method
path: "realitykit/audio/playaudio(_:)"
---

# playAudio(_:)

Prepares and plays multiple audio resources for synchronized playback

## Declaration

```swift
@discardableResult @MainActor static func playAudio(_ resourcesAndEntities: [(AudioResource, Entity)]) throws -> AudioPlaybackGroupController
```

## Parameters

- `resourcesAndEntities`: An array of tuples containing audio resources and their associated entities. The same entity can appear multiple times with different resources.

## Return Value

Return Value An AudioPlaybackGroupController for the synchronized group.

## Discussion

Discussion This method creates an AudioPlaybackGroupController that coordinates playback across multiple entity/resource pairs. All audio sources in the group will be synchronized to sample-accurate precision. After the controller is created, the play() method of the controller that it returns is immediately called. note: An error if the audio preparation fails. Usage Notes The same entity can be used with multiple resources in the same group Entities can participate in multiple groups simultaneously The completion handler fires when the longest resource finishes

## See Also

### Playing audio resources

- [playAudio(_:at:)](realitykit/audio/playaudio(_:at:).md)
- [prepareAudio(_:)](realitykit/audio/prepareaudio(_:).md)
