objc2_media_player/generated/
MPRemoteCommand.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
10/// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpremotecommandhandlerstatus?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct MPRemoteCommandHandlerStatus(pub NSInteger);
15impl MPRemoteCommandHandlerStatus {
16    /// There was no error executing the requested command.
17    #[doc(alias = "MPRemoteCommandHandlerStatusSuccess")]
18    pub const Success: Self = Self(0);
19    /// The command could not be executed because the requested content does not
20    /// exist in the current application state.
21    #[doc(alias = "MPRemoteCommandHandlerStatusNoSuchContent")]
22    pub const NoSuchContent: Self = Self(100);
23    /// The command could not be executed because there is no now playing item
24    /// available that is required for this command. As an example, an
25    /// application would return this error code if an "enable language option"
26    /// command is received, but nothing is currently playing.
27    #[doc(alias = "MPRemoteCommandHandlerStatusNoActionableNowPlayingItem")]
28    pub const NoActionableNowPlayingItem: Self = Self(110);
29    /// The command could not be executed because a device required
30    /// is not available. For instance, if headphones are required, or if a watch
31    /// app realizes that it needs the companion to fulfull a request.
32    #[doc(alias = "MPRemoteCommandHandlerStatusDeviceNotFound")]
33    pub const DeviceNotFound: Self = Self(120);
34    /// The command could not be executed for another reason.
35    #[doc(alias = "MPRemoteCommandHandlerStatusCommandFailed")]
36    pub const CommandFailed: Self = Self(200);
37}
38
39unsafe impl Encode for MPRemoteCommandHandlerStatus {
40    const ENCODING: Encoding = NSInteger::ENCODING;
41}
42
43unsafe impl RefEncode for MPRemoteCommandHandlerStatus {
44    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
45}
46
47extern_class!(
48    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpremotecommand?language=objc)
49    #[unsafe(super(NSObject))]
50    #[derive(Debug, PartialEq, Eq, Hash)]
51    pub struct MPRemoteCommand;
52);
53
54extern_conformance!(
55    unsafe impl NSObjectProtocol for MPRemoteCommand {}
56);
57
58impl MPRemoteCommand {
59    extern_methods!(
60        #[unsafe(method(new))]
61        #[unsafe(method_family = new)]
62        pub unsafe fn new() -> Retained<Self>;
63
64        #[unsafe(method(init))]
65        #[unsafe(method_family = init)]
66        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
67
68        /// Whether a button (for example) should be enabled and tappable for this
69        /// particular command.
70        #[unsafe(method(isEnabled))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn isEnabled(&self) -> bool;
73
74        /// Setter for [`isEnabled`][Self::isEnabled].
75        #[unsafe(method(setEnabled:))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn setEnabled(&self, enabled: bool);
78
79        /// # Safety
80        ///
81        /// - `target` should be of the correct type.
82        /// - `action` must be a valid selector.
83        #[unsafe(method(addTarget:action:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn addTarget_action(&self, target: &AnyObject, action: Sel);
86
87        /// # Safety
88        ///
89        /// - `target` should be of the correct type.
90        /// - `action` must be a valid selector.
91        #[unsafe(method(removeTarget:action:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn removeTarget_action(&self, target: &AnyObject, action: Option<Sel>);
94
95        /// # Safety
96        ///
97        /// `target` should be of the correct type.
98        #[unsafe(method(removeTarget:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn removeTarget(&self, target: Option<&AnyObject>);
101
102        #[cfg(all(feature = "MPRemoteCommandEvent", feature = "block2"))]
103        /// Returns an opaque object to act as the target.
104        #[unsafe(method(addTargetWithHandler:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn addTargetWithHandler(
107            &self,
108            handler: &block2::DynBlock<
109                dyn Fn(NonNull<MPRemoteCommandEvent>) -> MPRemoteCommandHandlerStatus,
110            >,
111        ) -> Retained<AnyObject>;
112    );
113}
114
115extern_class!(
116    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpskipintervalcommand?language=objc)
117    #[unsafe(super(MPRemoteCommand, NSObject))]
118    #[derive(Debug, PartialEq, Eq, Hash)]
119    pub struct MPSkipIntervalCommand;
120);
121
122extern_conformance!(
123    unsafe impl NSObjectProtocol for MPSkipIntervalCommand {}
124);
125
126impl MPSkipIntervalCommand {
127    extern_methods!(
128        /// An array of NSNumbers (NSTimeIntervals) that contain preferred skip intervals.
129        #[unsafe(method(preferredIntervals))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn preferredIntervals(&self) -> Retained<NSArray<NSNumber>>;
132
133        /// Setter for [`preferredIntervals`][Self::preferredIntervals].
134        ///
135        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
136        #[unsafe(method(setPreferredIntervals:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn setPreferredIntervals(&self, preferred_intervals: &NSArray<NSNumber>);
139    );
140}
141
142/// Methods declared on superclass `MPRemoteCommand`.
143impl MPSkipIntervalCommand {
144    extern_methods!(
145        #[unsafe(method(new))]
146        #[unsafe(method_family = new)]
147        pub unsafe fn new() -> Retained<Self>;
148
149        #[unsafe(method(init))]
150        #[unsafe(method_family = init)]
151        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
152    );
153}
154
155extern_class!(
156    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpfeedbackcommand?language=objc)
157    #[unsafe(super(MPRemoteCommand, NSObject))]
158    #[derive(Debug, PartialEq, Eq, Hash)]
159    pub struct MPFeedbackCommand;
160);
161
162extern_conformance!(
163    unsafe impl NSObjectProtocol for MPFeedbackCommand {}
164);
165
166impl MPFeedbackCommand {
167    extern_methods!(
168        /// Whether the feedback command is in an "active" state. An example of when a
169        /// feedback command would be active is if the user already "liked" a particular
170        /// content item.
171        #[unsafe(method(isActive))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn isActive(&self) -> bool;
174
175        /// Setter for [`isActive`][Self::isActive].
176        #[unsafe(method(setActive:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn setActive(&self, active: bool);
179
180        /// A localized string briefly describing the context of the command.
181        #[unsafe(method(localizedTitle))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn localizedTitle(&self) -> Retained<NSString>;
184
185        /// Setter for [`localizedTitle`][Self::localizedTitle].
186        ///
187        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
188        #[unsafe(method(setLocalizedTitle:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn setLocalizedTitle(&self, localized_title: &NSString);
191
192        /// An optional shorter version of the localized title for this feedback
193        /// command. MediaPlayer uses this property to display this command's title on
194        /// remote control interfaces with little screen space.
195        #[unsafe(method(localizedShortTitle))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn localizedShortTitle(&self) -> Retained<NSString>;
198
199        /// Setter for [`localizedShortTitle`][Self::localizedShortTitle].
200        ///
201        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
202        #[unsafe(method(setLocalizedShortTitle:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn setLocalizedShortTitle(&self, localized_short_title: &NSString);
205    );
206}
207
208/// Methods declared on superclass `MPRemoteCommand`.
209impl MPFeedbackCommand {
210    extern_methods!(
211        #[unsafe(method(new))]
212        #[unsafe(method_family = new)]
213        pub unsafe fn new() -> Retained<Self>;
214
215        #[unsafe(method(init))]
216        #[unsafe(method_family = init)]
217        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
218    );
219}
220
221extern_class!(
222    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpratingcommand?language=objc)
223    #[unsafe(super(MPRemoteCommand, NSObject))]
224    #[derive(Debug, PartialEq, Eq, Hash)]
225    pub struct MPRatingCommand;
226);
227
228extern_conformance!(
229    unsafe impl NSObjectProtocol for MPRatingCommand {}
230);
231
232impl MPRatingCommand {
233    extern_methods!(
234        /// Minimum rating for the command.
235        #[unsafe(method(minimumRating))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn minimumRating(&self) -> c_float;
238
239        /// Setter for [`minimumRating`][Self::minimumRating].
240        #[unsafe(method(setMinimumRating:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn setMinimumRating(&self, minimum_rating: c_float);
243
244        /// Maximum rating for the command.
245        #[unsafe(method(maximumRating))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn maximumRating(&self) -> c_float;
248
249        /// Setter for [`maximumRating`][Self::maximumRating].
250        #[unsafe(method(setMaximumRating:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn setMaximumRating(&self, maximum_rating: c_float);
253    );
254}
255
256/// Methods declared on superclass `MPRemoteCommand`.
257impl MPRatingCommand {
258    extern_methods!(
259        #[unsafe(method(new))]
260        #[unsafe(method_family = new)]
261        pub unsafe fn new() -> Retained<Self>;
262
263        #[unsafe(method(init))]
264        #[unsafe(method_family = init)]
265        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
266    );
267}
268
269extern_class!(
270    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangeplaybackratecommand?language=objc)
271    #[unsafe(super(MPRemoteCommand, NSObject))]
272    #[derive(Debug, PartialEq, Eq, Hash)]
273    pub struct MPChangePlaybackRateCommand;
274);
275
276extern_conformance!(
277    unsafe impl NSObjectProtocol for MPChangePlaybackRateCommand {}
278);
279
280impl MPChangePlaybackRateCommand {
281    extern_methods!(
282        /// An array of NSNumbers (floats) that contain supported playback rates that
283        /// the command can send.
284        #[unsafe(method(supportedPlaybackRates))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn supportedPlaybackRates(&self) -> Retained<NSArray<NSNumber>>;
287
288        /// Setter for [`supportedPlaybackRates`][Self::supportedPlaybackRates].
289        ///
290        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
291        #[unsafe(method(setSupportedPlaybackRates:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn setSupportedPlaybackRates(
294            &self,
295            supported_playback_rates: &NSArray<NSNumber>,
296        );
297    );
298}
299
300/// Methods declared on superclass `MPRemoteCommand`.
301impl MPChangePlaybackRateCommand {
302    extern_methods!(
303        #[unsafe(method(new))]
304        #[unsafe(method_family = new)]
305        pub unsafe fn new() -> Retained<Self>;
306
307        #[unsafe(method(init))]
308        #[unsafe(method_family = init)]
309        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
310    );
311}
312
313extern_class!(
314    /// Command for changing the current playback position in a now playing item.
315    /// Sends out MPChangePlaybackPositionCommandEvents.
316    ///
317    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangeplaybackpositioncommand?language=objc)
318    #[unsafe(super(MPRemoteCommand, NSObject))]
319    #[derive(Debug, PartialEq, Eq, Hash)]
320    pub struct MPChangePlaybackPositionCommand;
321);
322
323extern_conformance!(
324    unsafe impl NSObjectProtocol for MPChangePlaybackPositionCommand {}
325);
326
327impl MPChangePlaybackPositionCommand {
328    extern_methods!();
329}
330
331/// Methods declared on superclass `MPRemoteCommand`.
332impl MPChangePlaybackPositionCommand {
333    extern_methods!(
334        #[unsafe(method(new))]
335        #[unsafe(method_family = new)]
336        pub unsafe fn new() -> Retained<Self>;
337
338        #[unsafe(method(init))]
339        #[unsafe(method_family = init)]
340        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
341    );
342}
343
344extern_class!(
345    /// Command for changing the current shuffle mode to use during playback. To
346    /// update the system's current representation of your app's shuffle mode, set
347    /// the currentShuffleType property on this command to the proper shuffle type
348    /// value.
349    ///
350    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangeshufflemodecommand?language=objc)
351    #[unsafe(super(MPRemoteCommand, NSObject))]
352    #[derive(Debug, PartialEq, Eq, Hash)]
353    pub struct MPChangeShuffleModeCommand;
354);
355
356extern_conformance!(
357    unsafe impl NSObjectProtocol for MPChangeShuffleModeCommand {}
358);
359
360impl MPChangeShuffleModeCommand {
361    extern_methods!(
362        #[cfg(feature = "MPRemoteControlTypes")]
363        /// The app's current shuffle type.
364        #[unsafe(method(currentShuffleType))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn currentShuffleType(&self) -> MPShuffleType;
367
368        #[cfg(feature = "MPRemoteControlTypes")]
369        /// Setter for [`currentShuffleType`][Self::currentShuffleType].
370        #[unsafe(method(setCurrentShuffleType:))]
371        #[unsafe(method_family = none)]
372        pub unsafe fn setCurrentShuffleType(&self, current_shuffle_type: MPShuffleType);
373    );
374}
375
376/// Methods declared on superclass `MPRemoteCommand`.
377impl MPChangeShuffleModeCommand {
378    extern_methods!(
379        #[unsafe(method(new))]
380        #[unsafe(method_family = new)]
381        pub unsafe fn new() -> Retained<Self>;
382
383        #[unsafe(method(init))]
384        #[unsafe(method_family = init)]
385        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
386    );
387}
388
389extern_class!(
390    /// Command for changing the current repeat mode to use during playback. To
391    /// update the system's current representation of your app's repeat mode, set
392    /// the currentRepeatType property on this command to the proper repeat type
393    /// value.
394    ///
395    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangerepeatmodecommand?language=objc)
396    #[unsafe(super(MPRemoteCommand, NSObject))]
397    #[derive(Debug, PartialEq, Eq, Hash)]
398    pub struct MPChangeRepeatModeCommand;
399);
400
401extern_conformance!(
402    unsafe impl NSObjectProtocol for MPChangeRepeatModeCommand {}
403);
404
405impl MPChangeRepeatModeCommand {
406    extern_methods!(
407        #[cfg(feature = "MPRemoteControlTypes")]
408        /// The app's current repeat mode.
409        #[unsafe(method(currentRepeatType))]
410        #[unsafe(method_family = none)]
411        pub unsafe fn currentRepeatType(&self) -> MPRepeatType;
412
413        #[cfg(feature = "MPRemoteControlTypes")]
414        /// Setter for [`currentRepeatType`][Self::currentRepeatType].
415        #[unsafe(method(setCurrentRepeatType:))]
416        #[unsafe(method_family = none)]
417        pub unsafe fn setCurrentRepeatType(&self, current_repeat_type: MPRepeatType);
418    );
419}
420
421/// Methods declared on superclass `MPRemoteCommand`.
422impl MPChangeRepeatModeCommand {
423    extern_methods!(
424        #[unsafe(method(new))]
425        #[unsafe(method_family = new)]
426        pub unsafe fn new() -> Retained<Self>;
427
428        #[unsafe(method(init))]
429        #[unsafe(method_family = init)]
430        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
431    );
432}