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:))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn setCurrentDevice(&self, current_device: Option<&NSString>);
93
94 #[unsafe(method(delegate))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn delegate(
97 &self,
98 ) -> Option<Retained<ProtocolObject<dyn AVAudioPlayerDelegate>>>;
99
100 #[unsafe(method(setDelegate:))]
103 #[unsafe(method_family = none)]
104 pub unsafe fn setDelegate(
105 &self,
106 delegate: Option<&ProtocolObject<dyn AVAudioPlayerDelegate>>,
107 );
108
109 #[unsafe(method(url))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn url(&self) -> Option<Retained<NSURL>>;
112
113 #[unsafe(method(data))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn data(&self) -> Option<Retained<NSData>>;
116
117 #[unsafe(method(pan))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn pan(&self) -> c_float;
120
121 #[unsafe(method(setPan:))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn setPan(&self, pan: c_float);
125
126 #[unsafe(method(volume))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn volume(&self) -> c_float;
129
130 #[unsafe(method(setVolume:))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn setVolume(&self, volume: c_float);
134
135 #[unsafe(method(setVolume:fadeDuration:))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn setVolume_fadeDuration(&self, volume: c_float, duration: NSTimeInterval);
138
139 #[unsafe(method(enableRate))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn enableRate(&self) -> bool;
142
143 #[unsafe(method(setEnableRate:))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn setEnableRate(&self, enable_rate: bool);
147
148 #[unsafe(method(rate))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn rate(&self) -> c_float;
151
152 #[unsafe(method(setRate:))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn setRate(&self, rate: c_float);
156
157 #[unsafe(method(currentTime))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn currentTime(&self) -> NSTimeInterval;
160
161 #[unsafe(method(setCurrentTime:))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn setCurrentTime(&self, current_time: NSTimeInterval);
165
166 #[unsafe(method(deviceCurrentTime))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn deviceCurrentTime(&self) -> NSTimeInterval;
169
170 #[unsafe(method(numberOfLoops))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn numberOfLoops(&self) -> NSInteger;
173
174 #[unsafe(method(setNumberOfLoops:))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn setNumberOfLoops(&self, number_of_loops: NSInteger);
178
179 #[unsafe(method(settings))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn settings(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
182
183 #[cfg(feature = "AVAudioFormat")]
184 #[unsafe(method(format))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn format(&self) -> Retained<AVAudioFormat>;
187
188 #[unsafe(method(isMeteringEnabled))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn isMeteringEnabled(&self) -> bool;
191
192 #[unsafe(method(setMeteringEnabled:))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn setMeteringEnabled(&self, metering_enabled: bool);
196
197 #[unsafe(method(updateMeters))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn updateMeters(&self);
200
201 #[unsafe(method(peakPowerForChannel:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn peakPowerForChannel(&self, channel_number: NSUInteger) -> c_float;
204
205 #[unsafe(method(averagePowerForChannel:))]
206 #[unsafe(method_family = none)]
207 pub unsafe fn averagePowerForChannel(&self, channel_number: NSUInteger) -> c_float;
208
209 #[cfg(feature = "AVAudioSessionRoute")]
210 #[unsafe(method(channelAssignments))]
211 #[unsafe(method_family = none)]
212 pub unsafe fn channelAssignments(
213 &self,
214 ) -> Option<Retained<NSArray<AVAudioSessionChannelDescription>>>;
215
216 #[cfg(feature = "AVAudioSessionRoute")]
217 #[unsafe(method(setChannelAssignments:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn setChannelAssignments(
221 &self,
222 channel_assignments: Option<&NSArray<AVAudioSessionChannelDescription>>,
223 );
224 );
225}
226
227impl AVAudioPlayer {
229 extern_methods!(
230 #[unsafe(method(init))]
231 #[unsafe(method_family = init)]
232 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
233
234 #[unsafe(method(new))]
235 #[unsafe(method_family = new)]
236 pub unsafe fn new() -> Retained<Self>;
237 );
238}
239
240extern_protocol!(
241 pub unsafe trait AVAudioPlayerDelegate: NSObjectProtocol {
243 #[optional]
244 #[unsafe(method(audioPlayerDidFinishPlaying:successfully:))]
245 #[unsafe(method_family = none)]
246 unsafe fn audioPlayerDidFinishPlaying_successfully(
247 &self,
248 player: &AVAudioPlayer,
249 flag: bool,
250 );
251
252 #[optional]
253 #[unsafe(method(audioPlayerDecodeErrorDidOccur:error:))]
254 #[unsafe(method_family = none)]
255 unsafe fn audioPlayerDecodeErrorDidOccur_error(
256 &self,
257 player: &AVAudioPlayer,
258 error: Option<&NSError>,
259 );
260 }
261);