---
title: "init(contentsOf:soundBankURL:)"
framework: avfaudio
role: symbol
role_heading: Initializer
path: "avfaudio/avmidiplayer/init(contentsof:soundbankurl:)"
---

# init(contentsOf:soundBankURL:)

Creates a player to play a MIDI file with the specified soundbank.

## Declaration

```swift
init(contentsOf inURL: URL, soundBankURL bankURL: URL?) throws
```

## Parameters

- `inURL`: The URL of the file to play.
- `bankURL`: The URL of the sound bank. The sound bank must be in SoundFont2 or DLS format. In macOS, you can pass doc://com.apple.documentation/documentation/ObjectiveC/nil-227m0 for the bank URL argument to use the default sound bank. In iOS, you must always pass a valid bank file.

## Return Value

Return Value A new MIDI player, or nil if an error occurred.

## See Also

### Creating a MIDI player

- [init(data:soundBankURL:)](avfaudio/avmidiplayer/init(data:soundbankurl:).md)
