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