API reference

HapticClipPlayer Class

Extends IDisposable
HapticClipPlayer provides controls for playing a HapticClip.
It only plays valid HapticClips. A HapticClip assigned to a HapticClipPlayer can be played and stopped as often as required.

Protected Fields

The implementation of Haptics for HapticClipPlayer to use.

Properties

Whether the HapticClipPlayer is looping or not.
true if HapticClipPlayer is looping.
Sets/gets the HapticClipPlayer's amplitude.
During playback, the individual amplitudes in the clip will be multiplied by the player's amplitude. This changes how strong the vibration is. Amplitude values in a clip range from 0.0 to 1.0, and the result after applying the amplitude scale will be clipped to that range.An amplitude of 0.0 means that no vibration will be triggered, and an amplitude of 0.5 will result in the clip being played back at half of its amplitude.Example: if you apply amplitude of 5.0 to a haptic clip and the following amplitudes are in the clip: [0.2, 0.5, 0.1], the initial amplitude calculation would produce these values: [1.0, 2.5, 0.5] which will then be clamped like this: [1.0, 1.0, 0.5]This method can be called during active playback, in which case the amplitude is applied immediately, with a small delay in the tens of milliseconds. A value between zero and one (maximum) for the amplitude of the clip player. Values greater than one will be clipped. Negative values will cause an exception.
Sets/gets the HapticClipPlayer's frequency shift.
The frequencies in a haptic clip are in the range zero to one. This property shifts the individual frequencies up or down. The acceptable range of values is -1.0 to 1.0 inclusive.Once the frequencies in a clip have been shifted, they will be clamped to the playable range of frequency values, i.e. zero to one.Setting this property to 0.0 means that the frequencies will not be changed.Example: if you apply a frequency shift of 0.8 to a haptic clip and the following frequencies are in the clip: [0.1, 0.5, 0.0], the initial frequency shift calculation will produce these frequencies: [0.9, 1.3, 0.8] which will then be clamped like this: [0.9, 1.0, 0.8]This method can be called during active playback, in which case the frequency shift is applied immediately, with a small delay in the tens of milliseconds. A value between -1.0 and 1.0. Values outside this range will cause an exception.
Sets/gets the HapticClipPlayer's playback priority.
The playback engine of the Haptics SDK only ever renders the vibrations of a single HapticClipPlayer clip on the same controller at the same time. Meaning, haptic clips are not "mixed" when played back. If you have multiple players playing on the same controller at the same time, then only the player with the highest priority will trigger vibrations.Given the same priority value, the engine will always play the most recent clip that was started. All other players are muted, but continue tracking playback on their respective timeline (i.e. they are not paused). If a clip finishes (or is stopped), the engine will resume playback of the second most recent clip with an equal or higher priority level and so on.Example: Setting priority can be helpful if some haptic clips are more important than others, and allow us to design a hierarchy of haptic feedback based on context or the overall importance. For example, we could want a user to always receive a distinct haptic feedback if they are hit. Setting this "hit" clips priority higher compared to other haptic clips will ensure that the user always receives this haptic feedback.Priority values can be on the range of 0 (high priority) to 255 (low priority). By default, the priority value is set to 128 for every HapticClipPlayer. The player's priority can be changed before and during playback. An integer value on the range 0 to 255 (inclusive). Values outside this range will cause an exception.
Sets the HapticClipPlayer's current haptic clip.
This feature allows you to change the clip loaded in a clip player. If the player is currently playing it will be stopped. All other properties like amplitude, frequency shift, looping and priority are kept. A valid, JSON formatted, UTF-8 encoded haptic clip. Providing invalid clip data will cause an exception.

Fields

Get the duration of the loaded haptic clip of this HapticClipPlayer's instance.
The duration in seconds of the haptic clip.

Member Functions

Creates a HapticClipPlayer object for a given HapticClip.
Parameters
clip
The HapticClip to be played by this HapticClipPlayer. Providing invalid clip data will cause an exception.
Starts playback on the specified controller.
Parameters
controller
The controller to play back on.
Stops playback of the HapticClipPlayer.
Call this method to explicitly/deterministically release a HapticClipPlayer object, otherwise the garbage collector will release it. Of course, any calls to a disposed HapticClipPlayer will result in runtime errors.
A given HapticClip will not be freed until all HapticClipPlayers to which it is assigned have also been freed.

Protected Functions

Sets the Haptics implementation that HapticClipPlayer will call into for all haptics operations. This function is protected to allow derived classes to provide a custom implementation.
Releases the assigned clip and clip player from memory.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon