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        #[unsafe(method(addTarget:action:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn addTarget_action(&self, target: &AnyObject, action: Sel);
82
83        #[unsafe(method(removeTarget:action:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn removeTarget_action(&self, target: &AnyObject, action: Option<Sel>);
86
87        #[unsafe(method(removeTarget:))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn removeTarget(&self, target: Option<&AnyObject>);
90
91        #[cfg(all(feature = "MPRemoteCommandEvent", feature = "block2"))]
92        /// Returns an opaque object to act as the target.
93        #[unsafe(method(addTargetWithHandler:))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn addTargetWithHandler(
96            &self,
97            handler: &block2::DynBlock<
98                dyn Fn(NonNull<MPRemoteCommandEvent>) -> MPRemoteCommandHandlerStatus,
99            >,
100        ) -> Retained<AnyObject>;
101    );
102}
103
104extern_class!(
105    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpskipintervalcommand?language=objc)
106    #[unsafe(super(MPRemoteCommand, NSObject))]
107    #[derive(Debug, PartialEq, Eq, Hash)]
108    pub struct MPSkipIntervalCommand;
109);
110
111extern_conformance!(
112    unsafe impl NSObjectProtocol for MPSkipIntervalCommand {}
113);
114
115impl MPSkipIntervalCommand {
116    extern_methods!(
117        /// An array of NSNumbers (NSTimeIntervals) that contain preferred skip intervals.
118        #[unsafe(method(preferredIntervals))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn preferredIntervals(&self) -> Retained<NSArray<NSNumber>>;
121
122        /// Setter for [`preferredIntervals`][Self::preferredIntervals].
123        #[unsafe(method(setPreferredIntervals:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setPreferredIntervals(&self, preferred_intervals: &NSArray<NSNumber>);
126    );
127}
128
129/// Methods declared on superclass `MPRemoteCommand`.
130impl MPSkipIntervalCommand {
131    extern_methods!(
132        #[unsafe(method(new))]
133        #[unsafe(method_family = new)]
134        pub unsafe fn new() -> Retained<Self>;
135
136        #[unsafe(method(init))]
137        #[unsafe(method_family = init)]
138        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
139    );
140}
141
142extern_class!(
143    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpfeedbackcommand?language=objc)
144    #[unsafe(super(MPRemoteCommand, NSObject))]
145    #[derive(Debug, PartialEq, Eq, Hash)]
146    pub struct MPFeedbackCommand;
147);
148
149extern_conformance!(
150    unsafe impl NSObjectProtocol for MPFeedbackCommand {}
151);
152
153impl MPFeedbackCommand {
154    extern_methods!(
155        /// Whether the feedback command is in an "active" state. An example of when a
156        /// feedback command would be active is if the user already "liked" a particular
157        /// content item.
158        #[unsafe(method(isActive))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn isActive(&self) -> bool;
161
162        /// Setter for [`isActive`][Self::isActive].
163        #[unsafe(method(setActive:))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn setActive(&self, active: bool);
166
167        /// A localized string briefly describing the context of the command.
168        #[unsafe(method(localizedTitle))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn localizedTitle(&self) -> Retained<NSString>;
171
172        /// Setter for [`localizedTitle`][Self::localizedTitle].
173        #[unsafe(method(setLocalizedTitle:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn setLocalizedTitle(&self, localized_title: &NSString);
176
177        /// An optional shorter version of the localized title for this feedback
178        /// command. MediaPlayer uses this property to display this command's title on
179        /// remote control interfaces with little screen space.
180        #[unsafe(method(localizedShortTitle))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn localizedShortTitle(&self) -> Retained<NSString>;
183
184        /// Setter for [`localizedShortTitle`][Self::localizedShortTitle].
185        #[unsafe(method(setLocalizedShortTitle:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn setLocalizedShortTitle(&self, localized_short_title: &NSString);
188    );
189}
190
191/// Methods declared on superclass `MPRemoteCommand`.
192impl MPFeedbackCommand {
193    extern_methods!(
194        #[unsafe(method(new))]
195        #[unsafe(method_family = new)]
196        pub unsafe fn new() -> Retained<Self>;
197
198        #[unsafe(method(init))]
199        #[unsafe(method_family = init)]
200        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
201    );
202}
203
204extern_class!(
205    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpratingcommand?language=objc)
206    #[unsafe(super(MPRemoteCommand, NSObject))]
207    #[derive(Debug, PartialEq, Eq, Hash)]
208    pub struct MPRatingCommand;
209);
210
211extern_conformance!(
212    unsafe impl NSObjectProtocol for MPRatingCommand {}
213);
214
215impl MPRatingCommand {
216    extern_methods!(
217        /// Minimum rating for the command.
218        #[unsafe(method(minimumRating))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn minimumRating(&self) -> c_float;
221
222        /// Setter for [`minimumRating`][Self::minimumRating].
223        #[unsafe(method(setMinimumRating:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn setMinimumRating(&self, minimum_rating: c_float);
226
227        /// Maximum rating for the command.
228        #[unsafe(method(maximumRating))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn maximumRating(&self) -> c_float;
231
232        /// Setter for [`maximumRating`][Self::maximumRating].
233        #[unsafe(method(setMaximumRating:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setMaximumRating(&self, maximum_rating: c_float);
236    );
237}
238
239/// Methods declared on superclass `MPRemoteCommand`.
240impl MPRatingCommand {
241    extern_methods!(
242        #[unsafe(method(new))]
243        #[unsafe(method_family = new)]
244        pub unsafe fn new() -> Retained<Self>;
245
246        #[unsafe(method(init))]
247        #[unsafe(method_family = init)]
248        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
249    );
250}
251
252extern_class!(
253    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangeplaybackratecommand?language=objc)
254    #[unsafe(super(MPRemoteCommand, NSObject))]
255    #[derive(Debug, PartialEq, Eq, Hash)]
256    pub struct MPChangePlaybackRateCommand;
257);
258
259extern_conformance!(
260    unsafe impl NSObjectProtocol for MPChangePlaybackRateCommand {}
261);
262
263impl MPChangePlaybackRateCommand {
264    extern_methods!(
265        /// An array of NSNumbers (floats) that contain supported playback rates that
266        /// the command can send.
267        #[unsafe(method(supportedPlaybackRates))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn supportedPlaybackRates(&self) -> Retained<NSArray<NSNumber>>;
270
271        /// Setter for [`supportedPlaybackRates`][Self::supportedPlaybackRates].
272        #[unsafe(method(setSupportedPlaybackRates:))]
273        #[unsafe(method_family = none)]
274        pub unsafe fn setSupportedPlaybackRates(
275            &self,
276            supported_playback_rates: &NSArray<NSNumber>,
277        );
278    );
279}
280
281/// Methods declared on superclass `MPRemoteCommand`.
282impl MPChangePlaybackRateCommand {
283    extern_methods!(
284        #[unsafe(method(new))]
285        #[unsafe(method_family = new)]
286        pub unsafe fn new() -> Retained<Self>;
287
288        #[unsafe(method(init))]
289        #[unsafe(method_family = init)]
290        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
291    );
292}
293
294extern_class!(
295    /// Command for changing the current playback position in a now playing item.
296    /// Sends out MPChangePlaybackPositionCommandEvents.
297    ///
298    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangeplaybackpositioncommand?language=objc)
299    #[unsafe(super(MPRemoteCommand, NSObject))]
300    #[derive(Debug, PartialEq, Eq, Hash)]
301    pub struct MPChangePlaybackPositionCommand;
302);
303
304extern_conformance!(
305    unsafe impl NSObjectProtocol for MPChangePlaybackPositionCommand {}
306);
307
308impl MPChangePlaybackPositionCommand {
309    extern_methods!();
310}
311
312/// Methods declared on superclass `MPRemoteCommand`.
313impl MPChangePlaybackPositionCommand {
314    extern_methods!(
315        #[unsafe(method(new))]
316        #[unsafe(method_family = new)]
317        pub unsafe fn new() -> Retained<Self>;
318
319        #[unsafe(method(init))]
320        #[unsafe(method_family = init)]
321        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
322    );
323}
324
325extern_class!(
326    /// Command for changing the current shuffle mode to use during playback. To
327    /// update the system's current representation of your app's shuffle mode, set
328    /// the currentShuffleType property on this command to the proper shuffle type
329    /// value.
330    ///
331    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangeshufflemodecommand?language=objc)
332    #[unsafe(super(MPRemoteCommand, NSObject))]
333    #[derive(Debug, PartialEq, Eq, Hash)]
334    pub struct MPChangeShuffleModeCommand;
335);
336
337extern_conformance!(
338    unsafe impl NSObjectProtocol for MPChangeShuffleModeCommand {}
339);
340
341impl MPChangeShuffleModeCommand {
342    extern_methods!(
343        #[cfg(feature = "MPRemoteControlTypes")]
344        /// The app's current shuffle type.
345        #[unsafe(method(currentShuffleType))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn currentShuffleType(&self) -> MPShuffleType;
348
349        #[cfg(feature = "MPRemoteControlTypes")]
350        /// Setter for [`currentShuffleType`][Self::currentShuffleType].
351        #[unsafe(method(setCurrentShuffleType:))]
352        #[unsafe(method_family = none)]
353        pub unsafe fn setCurrentShuffleType(&self, current_shuffle_type: MPShuffleType);
354    );
355}
356
357/// Methods declared on superclass `MPRemoteCommand`.
358impl MPChangeShuffleModeCommand {
359    extern_methods!(
360        #[unsafe(method(new))]
361        #[unsafe(method_family = new)]
362        pub unsafe fn new() -> Retained<Self>;
363
364        #[unsafe(method(init))]
365        #[unsafe(method_family = init)]
366        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
367    );
368}
369
370extern_class!(
371    /// Command for changing the current repeat mode to use during playback. To
372    /// update the system's current representation of your app's repeat mode, set
373    /// the currentRepeatType property on this command to the proper repeat type
374    /// value.
375    ///
376    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangerepeatmodecommand?language=objc)
377    #[unsafe(super(MPRemoteCommand, NSObject))]
378    #[derive(Debug, PartialEq, Eq, Hash)]
379    pub struct MPChangeRepeatModeCommand;
380);
381
382extern_conformance!(
383    unsafe impl NSObjectProtocol for MPChangeRepeatModeCommand {}
384);
385
386impl MPChangeRepeatModeCommand {
387    extern_methods!(
388        #[cfg(feature = "MPRemoteControlTypes")]
389        /// The app's current repeat mode.
390        #[unsafe(method(currentRepeatType))]
391        #[unsafe(method_family = none)]
392        pub unsafe fn currentRepeatType(&self) -> MPRepeatType;
393
394        #[cfg(feature = "MPRemoteControlTypes")]
395        /// Setter for [`currentRepeatType`][Self::currentRepeatType].
396        #[unsafe(method(setCurrentRepeatType:))]
397        #[unsafe(method_family = none)]
398        pub unsafe fn setCurrentRepeatType(&self, current_repeat_type: MPRepeatType);
399    );
400}
401
402/// Methods declared on superclass `MPRemoteCommand`.
403impl MPChangeRepeatModeCommand {
404    extern_methods!(
405        #[unsafe(method(new))]
406        #[unsafe(method_family = new)]
407        pub unsafe fn new() -> Retained<Self>;
408
409        #[unsafe(method(init))]
410        #[unsafe(method_family = init)]
411        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
412    );
413}