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