A protocol that defines an advanced pattern player capable of looping, seeking, pausing, and resuming haptic playback.


protocol CHHapticAdvancedPatternPlayer


Create instances of this pattern player through a CHHapticEngine object by calling a factory method such as makeAdvancedPlayer(with:). When you ask an advanced pattern player to play, pause, or resume a haptic pattern, the player submits those commands to the haptic engine on your behalf.

Unlike CHHapticPatternPlayer, the advanced pattern player supports looping of haptic and audio patterns, by setting loopEnabled. The advanced pattern player can also call a block when the player finishes, through its completionHandler property.


Setting Playback Properties

var loopEnabled: Bool

A Boolean that determines whether the haptic repeats itself on completion.


var loopEnd: TimeInterval

The time at which to end looping haptic playback.


var playbackRate: Float

The playback rate of the haptic player.


var completionHandler: CHHapticAdvancedPatternPlayerCompletionHandler

A completion block that runs after the haptic finishes playing.


typealias CHHapticAdvancedPatternPlayerCompletionHandler

A typealias for the completion handler to run after a haptic finishes playback.

Controlling Playback

func pause(atTime: TimeInterval)

Pauses the haptic player during playback.


func resume(atTime: TimeInterval)

Resumes playing a paused haptic.


func seek(toOffset: TimeInterval)

Jumps to the specified offset time in playing the haptic.


Silencing Haptic Playback

var isMuted: Bool

A Boolean that silences all haptic and audio output from the player when set to true.



See Also

Creating Haptic Pattern Players

protocol CHHapticPatternPlayer

A protocol that defines a standard pattern player capable of playing haptic patterns with fixed parameters.

func makePlayer(with: CHHapticPattern) -> CHHapticPatternPlayer

Creates a standard haptic pattern player from a haptic pattern.

func makeAdvancedPlayer(with: CHHapticPattern) -> CHHapticAdvancedPatternPlayer

Creates an advanced haptic pattern player from a haptic pattern.