Protocol

CHHapticAdvancedPatternPlayer

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

Declaration

protocol CHHapticAdvancedPatternPlayer

Overview

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.

Topics

Setting Playback Properties

var loopEnabled: Bool

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

Required.

var loopEnd: TimeInterval

The time at which to end looping haptic playback.

Required.

var playbackRate: Float

The playback rate of the haptic player.

Required.

var completionHandler: CHHapticAdvancedPatternPlayerCompletionHandler

A completion block that runs after the haptic finishes playing.

Required.

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.

Required.

func resume(atTime: TimeInterval)

Resumes playing a paused haptic.

Required.

func seek(toOffset: TimeInterval)

Jumps to the specified offset time in playing the haptic.

Required.

Silencing Haptic Playback

var isMuted: Bool

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

Required.

Relationships

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.