An object that controls playback of a single audio item.


class WKAudioFilePlayer : NSObject


Use a player object to start and stop playback and to control the rate of playback. (The WKAudioFileQueuePlayer subclass extends the basic behavior to support playback of more than one item.)

The value of the player’s presentation-related properties are not valid until the underlying asset is loaded. Use the value of the status property to determine when it is valid to get the values of other properties. Specifically, wait until the status changes to WKAudioFilePlayerStatus.readyToPlay to access relevant properties.

The WKAudioFilePlayer class is key-value observing compliant for the currentItem, status, and rate properties. You can use an observer to detect changes to those properties and react accordingly. For information on how to observe properties using key-value observing, see Key-Value Observing Programming Guide.


Creating a Player

init(playerItem: WKAudioFilePlayerItem)

Creates and returns a player initialized with the specified player item.

func replaceCurrentItem(with: WKAudioFilePlayerItem?)

Replaces the current player item with a different one.

Configuring and Controlling Playback

func play()

Begins playback of the current item.

func pause()

Pauses playback of the associated item.

var rate: Float

The current rate of playback.

Getting Information About the Player

var currentItem: WKAudioFilePlayerItem?

The player’s current item.

var status: WKAudioFilePlayerStatus

The status of the player.

var error: Error?

An error that describes the cause of a failure.

Getting Timing Information

var currentTime: TimeInterval

The elapsed time for the current playing item.


enum WKAudioFilePlayerStatus

Constants that represent the status of the player.


Inherits From

Conforms To

See Also


Playing Background Audio

Enable background audio in your app to provide a seamless playback experience.

Adding a Now Playing View

Provide a view that controls the currently playing audio from your app.

class WKInterfaceVolumeControl

An interface element that lets users control the audio volume from the watch or a paired iPhone.

property list key PUICAutoLaunchAudioOptOut

A Boolean value indicating whether a watchOS app should opt out of automatically launching when its companion iOS app starts playing audio content.

Name: Opt out of Auto-launch Audio App (Watch)
class WKAudioFileQueuePlayer

An object that controls playback of one or more audio items.

class WKAudioFilePlayerItem

An object that manages the presentation state of an audio file while it is being played.

class WKAudioFileAsset

An object that stores a reference to an audio file and provides metadata information about that file.