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        /// This is a [weak property][objc2::topics::weak_property].
109        /// Setter for [`delegate`][Self::delegate].
110        #[unsafe(method(setDelegate:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn setDelegate(
113            &self,
114            delegate: Option<&ProtocolObject<dyn MPNowPlayingSessionDelegate>>,
115        );
116
117        /// When YES, now playing info will be automatically published, and nowPlayingInfoCenter must not be used.
118        /// Now playing info keys to be incorporated by automatic publishing can be set on the AVPlayerItem's nowPlayingInfo property.
119        #[unsafe(method(automaticallyPublishesNowPlayingInfo))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn automaticallyPublishesNowPlayingInfo(&self) -> bool;
122
123        /// Setter for [`automaticallyPublishesNowPlayingInfo`][Self::automaticallyPublishesNowPlayingInfo].
124        #[unsafe(method(setAutomaticallyPublishesNowPlayingInfo:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn setAutomaticallyPublishesNowPlayingInfo(
127            &self,
128            automatically_publishes_now_playing_info: bool,
129        );
130
131        #[cfg(feature = "MPNowPlayingInfoCenter")]
132        /// The now playing info center that is associated with this session.
133        #[unsafe(method(nowPlayingInfoCenter))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn nowPlayingInfoCenter(&self) -> Retained<MPNowPlayingInfoCenter>;
136
137        #[cfg(feature = "MPRemoteCommandCenter")]
138        /// The remote command center that is associated with this session.
139        #[unsafe(method(remoteCommandCenter))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn remoteCommandCenter(&self) -> Retained<MPRemoteCommandCenter>;
142
143        /// Returns a Boolean value indicating whether this session can become the App's active now playing session.
144        #[unsafe(method(canBecomeActive))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn canBecomeActive(&self) -> bool;
147
148        /// Returns a Boolean value indicating whether this session is the App's active now playing session.
149        #[unsafe(method(isActive))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn isActive(&self) -> bool;
152
153        #[cfg(feature = "block2")]
154        /// Asks the system to make this session the active now playing sessin for the App.
155        #[unsafe(method(becomeActiveIfPossibleWithCompletion:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn becomeActiveIfPossibleWithCompletion(
158            &self,
159            completion: Option<&block2::DynBlock<dyn Fn(Bool)>>,
160        );
161
162        #[cfg(feature = "objc2-av-foundation")]
163        /// Add AVPlayer instance to this session.
164        #[unsafe(method(addPlayer:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn addPlayer(&self, player: &AVPlayer);
167
168        #[cfg(feature = "objc2-av-foundation")]
169        /// Remove AVPlayer instance from this session.
170        #[unsafe(method(removePlayer:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn removePlayer(&self, player: &AVPlayer);
173    );
174}
175
176extern_protocol!(
177    /// [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpnowplayingsessiondelegate?language=objc)
178    pub unsafe trait MPNowPlayingSessionDelegate: NSObjectProtocol {
179        /// Tells the delegate that the session has changed its active status.
180        #[optional]
181        #[unsafe(method(nowPlayingSessionDidChangeActive:))]
182        #[unsafe(method_family = none)]
183        unsafe fn nowPlayingSessionDidChangeActive(
184            &self,
185            now_playing_session: &MPNowPlayingSession,
186        );
187
188        /// Tells the delegate that the session has changed its can become active status.
189        #[optional]
190        #[unsafe(method(nowPlayingSessionDidChangeCanBecomeActive:))]
191        #[unsafe(method_family = none)]
192        unsafe fn nowPlayingSessionDidChangeCanBecomeActive(
193            &self,
194            now_playing_session: &MPNowPlayingSession,
195        );
196    }
197);