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