objc2_media_player/generated/
MPNowPlayingSession.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::*;
6#[cfg(feature = "objc2-av-foundation")]
7use objc2_av_foundation::*;
8#[cfg(feature = "objc2-core-media")]
9use objc2_core_media::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14extern_class!(
15    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpadtimerange?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct MPAdTimeRange;
19);
20
21unsafe impl NSCopying for MPAdTimeRange {}
22
23unsafe impl CopyingHelper for MPAdTimeRange {
24    type Result = Self;
25}
26
27unsafe impl NSObjectProtocol for MPAdTimeRange {}
28
29impl MPAdTimeRange {
30    extern_methods!(
31        #[cfg(feature = "objc2-core-media")]
32        /// Represents a time range where an ad break exists in the current player item.
33        /// This value must be in bounds of the duration of the current player item.
34        #[unsafe(method(timeRange))]
35        #[unsafe(method_family = none)]
36        pub unsafe fn timeRange(&self) -> CMTimeRange;
37
38        #[cfg(feature = "objc2-core-media")]
39        /// Setter for [`timeRange`][Self::timeRange].
40        #[unsafe(method(setTimeRange:))]
41        #[unsafe(method_family = none)]
42        pub unsafe fn setTimeRange(&self, time_range: CMTimeRange);
43
44        #[unsafe(method(new))]
45        #[unsafe(method_family = new)]
46        pub unsafe fn new() -> Retained<Self>;
47
48        #[unsafe(method(init))]
49        #[unsafe(method_family = init)]
50        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
51
52        #[cfg(feature = "objc2-core-media")]
53        #[unsafe(method(initWithTimeRange:))]
54        #[unsafe(method_family = init)]
55        pub unsafe fn initWithTimeRange(
56            this: Allocated<Self>,
57            time_range: CMTimeRange,
58        ) -> Retained<Self>;
59    );
60}
61
62extern_class!(
63    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpnowplayingsession?language=objc)
64    #[unsafe(super(NSObject))]
65    #[derive(Debug, PartialEq, Eq, Hash)]
66    pub struct MPNowPlayingSession;
67);
68
69unsafe impl NSObjectProtocol for MPNowPlayingSession {}
70
71impl MPNowPlayingSession {
72    extern_methods!(
73        #[cfg(feature = "objc2-av-foundation")]
74        /// Creates a session associated with a given AVPlayer instance. This will assert if players is nil or empty.
75        #[unsafe(method(initWithPlayers:))]
76        #[unsafe(method_family = init)]
77        pub unsafe fn initWithPlayers(
78            this: Allocated<Self>,
79            players: &NSArray<AVPlayer>,
80        ) -> Retained<Self>;
81
82        #[unsafe(method(new))]
83        #[unsafe(method_family = new)]
84        pub unsafe fn new() -> Retained<Self>;
85
86        #[unsafe(method(init))]
87        #[unsafe(method_family = init)]
88        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
89
90        #[cfg(feature = "objc2-av-foundation")]
91        /// AVPlayer instances associated with this session.
92        #[unsafe(method(players))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn players(&self, mtm: MainThreadMarker) -> Retained<NSArray<AVPlayer>>;
95
96        #[unsafe(method(delegate))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn delegate(
99            &self,
100        ) -> Option<Retained<ProtocolObject<dyn MPNowPlayingSessionDelegate>>>;
101
102        /// This is a [weak property][objc2::topics::weak_property].
103        /// Setter for [`delegate`][Self::delegate].
104        #[unsafe(method(setDelegate:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn setDelegate(
107            &self,
108            delegate: Option<&ProtocolObject<dyn MPNowPlayingSessionDelegate>>,
109        );
110
111        /// When YES, now playing info will be automatically published, and nowPlayingInfoCenter must not be used.
112        /// Now playing info keys to be incorporated by automatic publishing can be set on the AVPlayerItem's nowPlayingInfo property.
113        #[unsafe(method(automaticallyPublishesNowPlayingInfo))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn automaticallyPublishesNowPlayingInfo(&self) -> bool;
116
117        /// Setter for [`automaticallyPublishesNowPlayingInfo`][Self::automaticallyPublishesNowPlayingInfo].
118        #[unsafe(method(setAutomaticallyPublishesNowPlayingInfo:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn setAutomaticallyPublishesNowPlayingInfo(
121            &self,
122            automatically_publishes_now_playing_info: bool,
123        );
124
125        #[cfg(feature = "MPNowPlayingInfoCenter")]
126        /// The now playing info center that is associated with this session.
127        #[unsafe(method(nowPlayingInfoCenter))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn nowPlayingInfoCenter(&self) -> Retained<MPNowPlayingInfoCenter>;
130
131        #[cfg(feature = "MPRemoteCommandCenter")]
132        /// The remote command center that is associated with this session.
133        #[unsafe(method(remoteCommandCenter))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn remoteCommandCenter(&self) -> Retained<MPRemoteCommandCenter>;
136
137        /// Returns a Boolean value indicating whether this session can become the App's active now playing session.
138        #[unsafe(method(canBecomeActive))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn canBecomeActive(&self) -> bool;
141
142        /// Returns a Boolean value indicating whether this session is the App's active now playing session.
143        #[unsafe(method(isActive))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn isActive(&self) -> bool;
146
147        #[cfg(feature = "block2")]
148        /// Asks the system to make this session the active now playing sessin for the App.
149        #[unsafe(method(becomeActiveIfPossibleWithCompletion:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn becomeActiveIfPossibleWithCompletion(
152            &self,
153            completion: Option<&block2::Block<dyn Fn(Bool)>>,
154        );
155
156        #[cfg(feature = "objc2-av-foundation")]
157        /// Add AVPlayer instance to this session.
158        #[unsafe(method(addPlayer:))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn addPlayer(&self, player: &AVPlayer);
161
162        #[cfg(feature = "objc2-av-foundation")]
163        /// Remove AVPlayer instance from this session.
164        #[unsafe(method(removePlayer:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn removePlayer(&self, player: &AVPlayer);
167    );
168}
169
170extern_protocol!(
171    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpnowplayingsessiondelegate?language=objc)
172    pub unsafe trait MPNowPlayingSessionDelegate: NSObjectProtocol {
173        /// Tells the delegate that the session has changed its active status.
174        #[optional]
175        #[unsafe(method(nowPlayingSessionDidChangeActive:))]
176        #[unsafe(method_family = none)]
177        unsafe fn nowPlayingSessionDidChangeActive(
178            &self,
179            now_playing_session: &MPNowPlayingSession,
180        );
181
182        /// Tells the delegate that the session has changed its can become active status.
183        #[optional]
184        #[unsafe(method(nowPlayingSessionDidChangeCanBecomeActive:))]
185        #[unsafe(method_family = none)]
186        unsafe fn nowPlayingSessionDidChangeCanBecomeActive(
187            &self,
188            now_playing_session: &MPNowPlayingSession,
189        );
190    }
191);