Initializer

init(contentsOf:)

Initializes and returns an audio player for playing a designated sound file.

Declaration

init(contentsOf url: URL) throws

Parameters

url

A URL identifying the sound file to play. The audio data must be in a format supported by Core Audio. For a list of supported formats, see Using Audio in Multimedia Programming Guide.

outError

If an error occurs, upon return the NSError object describes the error. Set to NULL to ignore errors.

Return Value

On success, an initialized AVAudioPlayer object. If nil, the outError parameter contains an NSError instance describing the problem.

Discussion

See Also

Initializing an AVAudioPlayer Object

init(data: Data)

Initializes and returns an audio player for playing a designated memory buffer.

init(contentsOf: URL, fileTypeHint: String?)

Initializes and returns an audio player using the specified URL and file type hint.

init(data: Data, fileTypeHint: String?)

Initializes and returns an audio player using the specified data and file type hint.