objc2_core_haptics/generated/
CHHapticPatternPlayer.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11    /// A protocol which defines operations for starting, stopping, and sending parameters to a pattern player.
12    ///
13    /// Instances of these objects are created via the factory methods such as
14    /// `CHHapticEngine(createPlayerWithPattern:error)`.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternplayer?language=objc)
17    pub unsafe trait CHHapticPatternPlayer: NSObjectProtocol {
18        /// Start playing the pattern at the specified time (see `CHHapticEngine(currentTime)`).
19        /// If 'time' is set to `CHHapticTimeImmediate`, the pattern is started as soon as possible.
20        #[unsafe(method(startAtTime:error:_))]
21        #[unsafe(method_family = none)]
22        unsafe fn startAtTime_error(&self, time: NSTimeInterval) -> Result<(), Retained<NSError>>;
23
24        /// Stop playing the pattern at the specified time (see `CHHapticEngine(currentTime)`).
25        /// If 'time' is set to `CHHapticTimeImmediate`, the pattern is stopped as soon as possible.
26        #[unsafe(method(stopAtTime:error:_))]
27        #[unsafe(method_family = none)]
28        unsafe fn stopAtTime_error(&self, time: NSTimeInterval) -> Result<(), Retained<NSError>>;
29
30        #[cfg(feature = "CHHapticParameter")]
31        /// Send an array of CHHapticDynamicParameters, starting at the specified time (see `CHHapticEngine(currentTime)`).
32        /// If 'time' is set to `CHHapticTimeImmediate`, the parameters are sent as soon as possible.
33        #[unsafe(method(sendParameters:atTime:error:_))]
34        #[unsafe(method_family = none)]
35        unsafe fn sendParameters_atTime_error(
36            &self,
37            parameters: &NSArray<CHHapticDynamicParameter>,
38            time: NSTimeInterval,
39        ) -> Result<(), Retained<NSError>>;
40
41        #[cfg(feature = "CHHapticParameter")]
42        /// Schedule a CHHapticParameterCurve, starting at the specified time (see `CHHapticEngine(currentTime)`).
43        /// If 'time' is set to `CHHapticTimeImmediate`, the parameter curve is scheduled as soon as possible.
44        ///
45        /// This method overrides the relativeTime property of the passed-in CHHapticParameterCurve,
46        /// setting it to this method's 'time' argument. All the curve's control point times will then be
47        /// calculated relative to that time.
48        #[unsafe(method(scheduleParameterCurve:atTime:error:_))]
49        #[unsafe(method_family = none)]
50        unsafe fn scheduleParameterCurve_atTime_error(
51            &self,
52            parameter_curve: &CHHapticParameterCurve,
53            time: NSTimeInterval,
54        ) -> Result<(), Retained<NSError>>;
55
56        /// Removes all pending commands and stops the player as soon as possible.
57        #[unsafe(method(cancelAndReturnError:_))]
58        #[unsafe(method_family = none)]
59        unsafe fn cancelAndReturnError(&self) -> Result<(), Retained<NSError>>;
60
61        /// When set to YES, the player's audio and haptic output will be silenced.
62        #[unsafe(method(isMuted))]
63        #[unsafe(method_family = none)]
64        unsafe fn isMuted(&self) -> bool;
65
66        /// Setter for [`isMuted`][Self::isMuted].
67        #[unsafe(method(setIsMuted:))]
68        #[unsafe(method_family = none)]
69        unsafe fn setIsMuted(&self, is_muted: bool);
70    }
71);
72
73/// Block which is called asynchronously when a CHHapticAdvancedPatternPlayer finishes playing.
74///
75/// Parameter `error`: If the call to start the player fails, this is set to a valid NSError describing the error.
76///
77/// In general, callbacks arrive on a non-main thread and it is the client's responsibility to handle them
78/// in a thread-safe manner.
79///
80/// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticadvancedpatternplayercompletionhandler?language=objc)
81#[cfg(feature = "block2")]
82pub type CHHapticAdvancedPatternPlayerCompletionHandler =
83    *mut block2::DynBlock<dyn Fn(*mut NSError)>;
84
85extern_protocol!(
86    /// A protocol which defines operations for pausing, resuming, seeking, and sending parameters to a pattern player.
87    ///
88    /// Instances of these objects are created via the factory methods such as `CHHapticEngine(createAdvancedPlayerWithPattern:error)`.
89    ///
90    /// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticadvancedpatternplayer?language=objc)
91    pub unsafe trait CHHapticAdvancedPatternPlayer: CHHapticPatternPlayer {
92        /// Pause playback of the pattern at the specified time (see `CHHapticEngine(currentTime)`).
93        ///
94        /// If 'time' is set to `CHHapticTimeImmediate`, the pattern will be paused immediately.
95        #[unsafe(method(pauseAtTime:error:_))]
96        #[unsafe(method_family = none)]
97        unsafe fn pauseAtTime_error(&self, time: NSTimeInterval) -> Result<(), Retained<NSError>>;
98
99        /// Resume playback on a previously-paused player at the specified time (see `CHHapticEngine(currentTime)`).
100        ///
101        /// If 'time' is set to `CHHapticTimeImmediate`, the pattern is resumed as soon as possible.
102        /// Playback will resume at the time offset in the pattern at which it was paused.
103        #[unsafe(method(resumeAtTime:error:_))]
104        #[unsafe(method_family = none)]
105        unsafe fn resumeAtTime_error(&self, time: NSTimeInterval) -> Result<(), Retained<NSError>>;
106
107        /// Set the playback position on an active player to the specified offset time.
108        ///
109        /// If 'offsetTime' is set to 0.0, the pattern will start from the beginning.  If
110        /// set to >= the duration of the pattern, playback will terminate as soon as possible
111        /// unless the player is looped, in which case playback will start at the beginning of
112        /// the loop.
113        #[unsafe(method(seekToOffset:error:_))]
114        #[unsafe(method_family = none)]
115        unsafe fn seekToOffset_error(
116            &self,
117            offset_time: NSTimeInterval,
118        ) -> Result<(), Retained<NSError>>;
119
120        /// When set to YES, the player will loop back to the beginning of the pattern whenever playback
121        /// reaches the `loopEnd` time.
122        #[unsafe(method(loopEnabled))]
123        #[unsafe(method_family = none)]
124        unsafe fn loopEnabled(&self) -> bool;
125
126        /// Setter for [`loopEnabled`][Self::loopEnabled].
127        #[unsafe(method(setLoopEnabled:))]
128        #[unsafe(method_family = none)]
129        unsafe fn setLoopEnabled(&self, loop_enabled: bool);
130
131        /// The time in seconds at which the pattern will loop back if looping is enabled.
132        ///
133        /// If set to 0.0, the loop length will be set to the end of the last event in the pattern.
134        #[unsafe(method(loopEnd))]
135        #[unsafe(method_family = none)]
136        unsafe fn loopEnd(&self) -> NSTimeInterval;
137
138        /// Setter for [`loopEnd`][Self::loopEnd].
139        #[unsafe(method(setLoopEnd:))]
140        #[unsafe(method_family = none)]
141        unsafe fn setLoopEnd(&self, loop_end: NSTimeInterval);
142
143        /// Allows a pattern to be played back at any multiple of its normal rate.  The rate can be adjusted
144        /// at any point before or during pattern playback.
145        ///
146        /// This rate factor scales the relative times of all events and parameters as they are played, as well as the
147        /// durations of Continuous events and the `loopEnd` time.  It does not affect the pitches of the events.
148        /// Any value greater than 0.0 is valid; all others are ignored.
149        #[unsafe(method(playbackRate))]
150        #[unsafe(method_family = none)]
151        unsafe fn playbackRate(&self) -> c_float;
152
153        /// Setter for [`playbackRate`][Self::playbackRate].
154        #[unsafe(method(setPlaybackRate:))]
155        #[unsafe(method_family = none)]
156        unsafe fn setPlaybackRate(&self, playback_rate: c_float);
157
158        /// When set to YES, all audio and haptic output will be silenced.
159        #[unsafe(method(isMuted))]
160        #[unsafe(method_family = none)]
161        unsafe fn isMuted(&self) -> bool;
162
163        /// Setter for [`isMuted`][Self::isMuted].
164        #[unsafe(method(setIsMuted:))]
165        #[unsafe(method_family = none)]
166        unsafe fn setIsMuted(&self, is_muted: bool);
167
168        #[cfg(feature = "block2")]
169        /// The block or enclosure that will be called when the player finishes.
170        ///
171        /// # Safety
172        ///
173        /// The returned block's argument must be a valid pointer or null.
174        #[unsafe(method(completionHandler))]
175        #[unsafe(method_family = none)]
176        unsafe fn completionHandler(&self) -> CHHapticAdvancedPatternPlayerCompletionHandler;
177
178        #[cfg(feature = "block2")]
179        /// Setter for [`completionHandler`][Self::completionHandler].
180        ///
181        /// # Safety
182        ///
183        /// `completion_handler` must be a valid pointer.
184        #[unsafe(method(setCompletionHandler:))]
185        #[unsafe(method_family = none)]
186        unsafe fn setCompletionHandler(
187            &self,
188            completion_handler: CHHapticAdvancedPatternPlayerCompletionHandler,
189        );
190    }
191);