objc2_avf_audio/generated/
AVAudioPlayer.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
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioplayer?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct AVAudioPlayer;
15);
16
17unsafe impl NSObjectProtocol for AVAudioPlayer {}
18
19impl AVAudioPlayer {
20    extern_methods!(
21        #[unsafe(method(initWithContentsOfURL:error:_))]
22        #[unsafe(method_family = init)]
23        pub unsafe fn initWithContentsOfURL_error(
24            this: Allocated<Self>,
25            url: &NSURL,
26        ) -> Result<Retained<Self>, Retained<NSError>>;
27
28        #[unsafe(method(initWithData:error:_))]
29        #[unsafe(method_family = init)]
30        pub unsafe fn initWithData_error(
31            this: Allocated<Self>,
32            data: &NSData,
33        ) -> Result<Retained<Self>, Retained<NSError>>;
34
35        #[unsafe(method(initWithContentsOfURL:fileTypeHint:error:_))]
36        #[unsafe(method_family = init)]
37        pub unsafe fn initWithContentsOfURL_fileTypeHint_error(
38            this: Allocated<Self>,
39            url: &NSURL,
40            uti_string: Option<&NSString>,
41        ) -> Result<Retained<Self>, Retained<NSError>>;
42
43        #[unsafe(method(initWithData:fileTypeHint:error:_))]
44        #[unsafe(method_family = init)]
45        pub unsafe fn initWithData_fileTypeHint_error(
46            this: Allocated<Self>,
47            data: &NSData,
48            uti_string: Option<&NSString>,
49        ) -> Result<Retained<Self>, Retained<NSError>>;
50
51        #[unsafe(method(prepareToPlay))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn prepareToPlay(&self) -> bool;
54
55        #[unsafe(method(play))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn play(&self) -> bool;
58
59        #[unsafe(method(playAtTime:))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn playAtTime(&self, time: NSTimeInterval) -> bool;
62
63        #[unsafe(method(pause))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn pause(&self);
66
67        #[unsafe(method(stop))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn stop(&self);
70
71        #[unsafe(method(isPlaying))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn isPlaying(&self) -> bool;
74
75        #[unsafe(method(numberOfChannels))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn numberOfChannels(&self) -> NSUInteger;
78
79        #[unsafe(method(duration))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn duration(&self) -> NSTimeInterval;
82
83        #[unsafe(method(currentDevice))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn currentDevice(&self) -> Option<Retained<NSString>>;
86
87        /// Setter for [`currentDevice`][Self::currentDevice].
88        #[unsafe(method(setCurrentDevice:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn setCurrentDevice(&self, current_device: Option<&NSString>);
91
92        #[unsafe(method(delegate))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn delegate(
95            &self,
96        ) -> Option<Retained<ProtocolObject<dyn AVAudioPlayerDelegate>>>;
97
98        /// This is a [weak property][objc2::topics::weak_property].
99        /// Setter for [`delegate`][Self::delegate].
100        #[unsafe(method(setDelegate:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn setDelegate(
103            &self,
104            delegate: Option<&ProtocolObject<dyn AVAudioPlayerDelegate>>,
105        );
106
107        #[unsafe(method(url))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn url(&self) -> Option<Retained<NSURL>>;
110
111        #[unsafe(method(data))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn data(&self) -> Option<Retained<NSData>>;
114
115        #[unsafe(method(pan))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn pan(&self) -> c_float;
118
119        /// Setter for [`pan`][Self::pan].
120        #[unsafe(method(setPan:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setPan(&self, pan: c_float);
123
124        #[unsafe(method(volume))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn volume(&self) -> c_float;
127
128        /// Setter for [`volume`][Self::volume].
129        #[unsafe(method(setVolume:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn setVolume(&self, volume: c_float);
132
133        #[unsafe(method(setVolume:fadeDuration:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn setVolume_fadeDuration(&self, volume: c_float, duration: NSTimeInterval);
136
137        #[unsafe(method(enableRate))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn enableRate(&self) -> bool;
140
141        /// Setter for [`enableRate`][Self::enableRate].
142        #[unsafe(method(setEnableRate:))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn setEnableRate(&self, enable_rate: bool);
145
146        #[unsafe(method(rate))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn rate(&self) -> c_float;
149
150        /// Setter for [`rate`][Self::rate].
151        #[unsafe(method(setRate:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn setRate(&self, rate: c_float);
154
155        #[unsafe(method(currentTime))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn currentTime(&self) -> NSTimeInterval;
158
159        /// Setter for [`currentTime`][Self::currentTime].
160        #[unsafe(method(setCurrentTime:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setCurrentTime(&self, current_time: NSTimeInterval);
163
164        #[unsafe(method(deviceCurrentTime))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn deviceCurrentTime(&self) -> NSTimeInterval;
167
168        #[unsafe(method(numberOfLoops))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn numberOfLoops(&self) -> NSInteger;
171
172        /// Setter for [`numberOfLoops`][Self::numberOfLoops].
173        #[unsafe(method(setNumberOfLoops:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn setNumberOfLoops(&self, number_of_loops: NSInteger);
176
177        #[unsafe(method(settings))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn settings(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
180
181        #[cfg(feature = "AVAudioFormat")]
182        #[unsafe(method(format))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn format(&self) -> Retained<AVAudioFormat>;
185
186        #[unsafe(method(isMeteringEnabled))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn isMeteringEnabled(&self) -> bool;
189
190        /// Setter for [`isMeteringEnabled`][Self::isMeteringEnabled].
191        #[unsafe(method(setMeteringEnabled:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn setMeteringEnabled(&self, metering_enabled: bool);
194
195        #[unsafe(method(updateMeters))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn updateMeters(&self);
198
199        #[unsafe(method(peakPowerForChannel:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn peakPowerForChannel(&self, channel_number: NSUInteger) -> c_float;
202
203        #[unsafe(method(averagePowerForChannel:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn averagePowerForChannel(&self, channel_number: NSUInteger) -> c_float;
206
207        #[cfg(feature = "AVAudioSessionRoute")]
208        #[unsafe(method(channelAssignments))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn channelAssignments(
211            &self,
212        ) -> Option<Retained<NSArray<AVAudioSessionChannelDescription>>>;
213
214        #[cfg(feature = "AVAudioSessionRoute")]
215        /// Setter for [`channelAssignments`][Self::channelAssignments].
216        #[unsafe(method(setChannelAssignments:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn setChannelAssignments(
219            &self,
220            channel_assignments: Option<&NSArray<AVAudioSessionChannelDescription>>,
221        );
222    );
223}
224
225/// Methods declared on superclass `NSObject`.
226impl AVAudioPlayer {
227    extern_methods!(
228        #[unsafe(method(init))]
229        #[unsafe(method_family = init)]
230        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
231
232        #[unsafe(method(new))]
233        #[unsafe(method_family = new)]
234        pub unsafe fn new() -> Retained<Self>;
235    );
236}
237
238extern_protocol!(
239    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioplayerdelegate?language=objc)
240    pub unsafe trait AVAudioPlayerDelegate: NSObjectProtocol {
241        #[optional]
242        #[unsafe(method(audioPlayerDidFinishPlaying:successfully:))]
243        #[unsafe(method_family = none)]
244        unsafe fn audioPlayerDidFinishPlaying_successfully(
245            &self,
246            player: &AVAudioPlayer,
247            flag: bool,
248        );
249
250        #[optional]
251        #[unsafe(method(audioPlayerDecodeErrorDidOccur:error:))]
252        #[unsafe(method_family = none)]
253        unsafe fn audioPlayerDecodeErrorDidOccur_error(
254            &self,
255            player: &AVAudioPlayer,
256            error: Option<&NSError>,
257        );
258    }
259);