objc2-media-player 0.3.2

Bindings to the MediaPlayer framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpremotecommandhandlerstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MPRemoteCommandHandlerStatus(pub NSInteger);
impl MPRemoteCommandHandlerStatus {
    /// There was no error executing the requested command.
    #[doc(alias = "MPRemoteCommandHandlerStatusSuccess")]
    pub const Success: Self = Self(0);
    /// The command could not be executed because the requested content does not
    /// exist in the current application state.
    #[doc(alias = "MPRemoteCommandHandlerStatusNoSuchContent")]
    pub const NoSuchContent: Self = Self(100);
    /// The command could not be executed because there is no now playing item
    /// available that is required for this command. As an example, an
    /// application would return this error code if an "enable language option"
    /// command is received, but nothing is currently playing.
    #[doc(alias = "MPRemoteCommandHandlerStatusNoActionableNowPlayingItem")]
    pub const NoActionableNowPlayingItem: Self = Self(110);
    /// The command could not be executed because a device required
    /// is not available. For instance, if headphones are required, or if a watch
    /// app realizes that it needs the companion to fulfull a request.
    #[doc(alias = "MPRemoteCommandHandlerStatusDeviceNotFound")]
    pub const DeviceNotFound: Self = Self(120);
    /// The command could not be executed for another reason.
    #[doc(alias = "MPRemoteCommandHandlerStatusCommandFailed")]
    pub const CommandFailed: Self = Self(200);
}

unsafe impl Encode for MPRemoteCommandHandlerStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for MPRemoteCommandHandlerStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpremotecommand?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPRemoteCommand;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MPRemoteCommand {}
);

impl MPRemoteCommand {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// Whether a button (for example) should be enabled and tappable for this
        /// particular command.
        #[unsafe(method(isEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isEnabled(&self) -> bool;

        /// Setter for [`isEnabled`][Self::isEnabled].
        #[unsafe(method(setEnabled:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setEnabled(&self, enabled: bool);

        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(addTarget:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addTarget_action(&self, target: &AnyObject, action: Sel);

        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(removeTarget:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeTarget_action(&self, target: &AnyObject, action: Option<Sel>);

        /// # Safety
        ///
        /// `target` should be of the correct type.
        #[unsafe(method(removeTarget:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeTarget(&self, target: Option<&AnyObject>);

        #[cfg(all(feature = "MPRemoteCommandEvent", feature = "block2"))]
        /// Returns an opaque object to act as the target.
        #[unsafe(method(addTargetWithHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addTargetWithHandler(
            &self,
            handler: &block2::DynBlock<
                dyn Fn(NonNull<MPRemoteCommandEvent>) -> MPRemoteCommandHandlerStatus,
            >,
        ) -> Retained<AnyObject>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpskipintervalcommand?language=objc)
    #[unsafe(super(MPRemoteCommand, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPSkipIntervalCommand;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MPSkipIntervalCommand {}
);

impl MPSkipIntervalCommand {
    extern_methods!(
        /// An array of NSNumbers (NSTimeIntervals) that contain preferred skip intervals.
        #[unsafe(method(preferredIntervals))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredIntervals(&self) -> Retained<NSArray<NSNumber>>;

        /// Setter for [`preferredIntervals`][Self::preferredIntervals].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPreferredIntervals:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredIntervals(&self, preferred_intervals: &NSArray<NSNumber>);
    );
}

/// Methods declared on superclass `MPRemoteCommand`.
impl MPSkipIntervalCommand {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpfeedbackcommand?language=objc)
    #[unsafe(super(MPRemoteCommand, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPFeedbackCommand;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MPFeedbackCommand {}
);

impl MPFeedbackCommand {
    extern_methods!(
        /// Whether the feedback command is in an "active" state. An example of when a
        /// feedback command would be active is if the user already "liked" a particular
        /// content item.
        #[unsafe(method(isActive))]
        #[unsafe(method_family = none)]
        pub unsafe fn isActive(&self) -> bool;

        /// Setter for [`isActive`][Self::isActive].
        #[unsafe(method(setActive:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setActive(&self, active: bool);

        /// A localized string briefly describing the context of the command.
        #[unsafe(method(localizedTitle))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedTitle(&self) -> Retained<NSString>;

        /// Setter for [`localizedTitle`][Self::localizedTitle].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setLocalizedTitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLocalizedTitle(&self, localized_title: &NSString);

        /// An optional shorter version of the localized title for this feedback
        /// command. MediaPlayer uses this property to display this command's title on
        /// remote control interfaces with little screen space.
        #[unsafe(method(localizedShortTitle))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedShortTitle(&self) -> Retained<NSString>;

        /// Setter for [`localizedShortTitle`][Self::localizedShortTitle].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setLocalizedShortTitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLocalizedShortTitle(&self, localized_short_title: &NSString);
    );
}

/// Methods declared on superclass `MPRemoteCommand`.
impl MPFeedbackCommand {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpratingcommand?language=objc)
    #[unsafe(super(MPRemoteCommand, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPRatingCommand;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MPRatingCommand {}
);

impl MPRatingCommand {
    extern_methods!(
        /// Minimum rating for the command.
        #[unsafe(method(minimumRating))]
        #[unsafe(method_family = none)]
        pub unsafe fn minimumRating(&self) -> c_float;

        /// Setter for [`minimumRating`][Self::minimumRating].
        #[unsafe(method(setMinimumRating:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMinimumRating(&self, minimum_rating: c_float);

        /// Maximum rating for the command.
        #[unsafe(method(maximumRating))]
        #[unsafe(method_family = none)]
        pub unsafe fn maximumRating(&self) -> c_float;

        /// Setter for [`maximumRating`][Self::maximumRating].
        #[unsafe(method(setMaximumRating:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaximumRating(&self, maximum_rating: c_float);
    );
}

/// Methods declared on superclass `MPRemoteCommand`.
impl MPRatingCommand {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangeplaybackratecommand?language=objc)
    #[unsafe(super(MPRemoteCommand, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPChangePlaybackRateCommand;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MPChangePlaybackRateCommand {}
);

impl MPChangePlaybackRateCommand {
    extern_methods!(
        /// An array of NSNumbers (floats) that contain supported playback rates that
        /// the command can send.
        #[unsafe(method(supportedPlaybackRates))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportedPlaybackRates(&self) -> Retained<NSArray<NSNumber>>;

        /// Setter for [`supportedPlaybackRates`][Self::supportedPlaybackRates].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSupportedPlaybackRates:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSupportedPlaybackRates(
            &self,
            supported_playback_rates: &NSArray<NSNumber>,
        );
    );
}

/// Methods declared on superclass `MPRemoteCommand`.
impl MPChangePlaybackRateCommand {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

extern_class!(
    /// Command for changing the current playback position in a now playing item.
    /// Sends out MPChangePlaybackPositionCommandEvents.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangeplaybackpositioncommand?language=objc)
    #[unsafe(super(MPRemoteCommand, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPChangePlaybackPositionCommand;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MPChangePlaybackPositionCommand {}
);

impl MPChangePlaybackPositionCommand {
    extern_methods!();
}

/// Methods declared on superclass `MPRemoteCommand`.
impl MPChangePlaybackPositionCommand {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

extern_class!(
    /// Command for changing the current shuffle mode to use during playback. To
    /// update the system's current representation of your app's shuffle mode, set
    /// the currentShuffleType property on this command to the proper shuffle type
    /// value.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangeshufflemodecommand?language=objc)
    #[unsafe(super(MPRemoteCommand, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPChangeShuffleModeCommand;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MPChangeShuffleModeCommand {}
);

impl MPChangeShuffleModeCommand {
    extern_methods!(
        #[cfg(feature = "MPRemoteControlTypes")]
        /// The app's current shuffle type.
        #[unsafe(method(currentShuffleType))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentShuffleType(&self) -> MPShuffleType;

        #[cfg(feature = "MPRemoteControlTypes")]
        /// Setter for [`currentShuffleType`][Self::currentShuffleType].
        #[unsafe(method(setCurrentShuffleType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCurrentShuffleType(&self, current_shuffle_type: MPShuffleType);
    );
}

/// Methods declared on superclass `MPRemoteCommand`.
impl MPChangeShuffleModeCommand {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

extern_class!(
    /// Command for changing the current repeat mode to use during playback. To
    /// update the system's current representation of your app's repeat mode, set
    /// the currentRepeatType property on this command to the proper repeat type
    /// value.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpchangerepeatmodecommand?language=objc)
    #[unsafe(super(MPRemoteCommand, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPChangeRepeatModeCommand;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MPChangeRepeatModeCommand {}
);

impl MPChangeRepeatModeCommand {
    extern_methods!(
        #[cfg(feature = "MPRemoteControlTypes")]
        /// The app's current repeat mode.
        #[unsafe(method(currentRepeatType))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentRepeatType(&self) -> MPRepeatType;

        #[cfg(feature = "MPRemoteControlTypes")]
        /// Setter for [`currentRepeatType`][Self::currentRepeatType].
        #[unsafe(method(setCurrentRepeatType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCurrentRepeatType(&self, current_repeat_type: MPRepeatType);
    );
}

/// Methods declared on superclass `MPRemoteCommand`.
impl MPChangeRepeatModeCommand {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}