<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKAction/playSoundFileNamed(_:waitForCompletion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKAction(cm)playSoundFileNamed:waitForCompletion:"
  },
  "title" : "playSoundFileNamed(_:waitForCompletion:)"
}
-->

# playSoundFileNamed(_:waitForCompletion:)

Creates an action that plays a sound.

```
class func playSoundFileNamed(_ soundFile: String, waitForCompletion wait: Bool) -> SKAction
```

## Parameters

`soundFile`

The name of a sound file in the app’s bundle.

`wait`

If <doc://com.apple.documentation/documentation/Swift/true>, the duration of this action is the same as the length of the audio playback. If <doc://com.apple.documentation/documentation/Swift/false>, the action is considered to have completed immediately.

## Return Value

A new action object.

## Discussion

Use [`SKAction`](/documentation/SpriteKit/SKAction) `playSoundFileNamed:waitForCompletion:` only for short incidentals. Use <doc://com.apple.documentation/documentation/AVFAudio/AVAudioPlayer> for long running background music. This action is not reversible; the reversed action is identical to the original action.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)