objc2_app_kit/generated/
NSSound.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern "C" {
11 #[cfg(feature = "NSPasteboard")]
13 pub static NSSoundPboardType: &'static NSPasteboardType;
14}
15
16pub type NSSoundName = NSString;
18
19pub type NSSoundPlaybackDeviceIdentifier = NSString;
21
22extern_class!(
23 #[unsafe(super(NSObject))]
25 #[derive(Debug, PartialEq, Eq, Hash)]
26 pub struct NSSound;
27);
28
29extern_conformance!(
30 unsafe impl NSCoding for NSSound {}
31);
32
33extern_conformance!(
34 unsafe impl NSCopying for NSSound {}
35);
36
37unsafe impl CopyingHelper for NSSound {
38 type Result = Self;
39}
40
41extern_conformance!(
42 unsafe impl NSObjectProtocol for NSSound {}
43);
44
45#[cfg(feature = "NSPasteboard")]
46extern_conformance!(
47 unsafe impl NSPasteboardReading for NSSound {}
48);
49
50#[cfg(feature = "NSPasteboard")]
51extern_conformance!(
52 unsafe impl NSPasteboardWriting for NSSound {}
53);
54
55extern_conformance!(
56 unsafe impl NSSecureCoding for NSSound {}
57);
58
59impl NSSound {
60 extern_methods!(
61 #[unsafe(method(soundNamed:))]
62 #[unsafe(method_family = none)]
63 pub fn soundNamed(name: &NSSoundName) -> Option<Retained<NSSound>>;
64
65 #[unsafe(method(initWithContentsOfURL:byReference:))]
66 #[unsafe(method_family = init)]
67 pub fn initWithContentsOfURL_byReference(
68 this: Allocated<Self>,
69 url: &NSURL,
70 by_ref: bool,
71 ) -> Option<Retained<Self>>;
72
73 #[unsafe(method(initWithContentsOfFile:byReference:))]
74 #[unsafe(method_family = init)]
75 pub fn initWithContentsOfFile_byReference(
76 this: Allocated<Self>,
77 path: &NSString,
78 by_ref: bool,
79 ) -> Option<Retained<Self>>;
80
81 #[unsafe(method(initWithData:))]
82 #[unsafe(method_family = init)]
83 pub fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;
84
85 #[unsafe(method(setName:))]
86 #[unsafe(method_family = none)]
87 pub fn setName(&self, string: Option<&NSSoundName>) -> bool;
88
89 #[unsafe(method(name))]
90 #[unsafe(method_family = none)]
91 pub fn name(&self) -> Option<Retained<NSSoundName>>;
92
93 #[cfg(feature = "NSPasteboard")]
94 #[unsafe(method(canInitWithPasteboard:))]
95 #[unsafe(method_family = none)]
96 pub fn canInitWithPasteboard(pasteboard: &NSPasteboard) -> bool;
97
98 #[unsafe(method(soundUnfilteredTypes))]
99 #[unsafe(method_family = none)]
100 pub fn soundUnfilteredTypes() -> Retained<NSArray<NSString>>;
101
102 #[cfg(feature = "NSPasteboard")]
103 #[unsafe(method(initWithPasteboard:))]
104 #[unsafe(method_family = init)]
105 pub fn initWithPasteboard(
106 this: Allocated<Self>,
107 pasteboard: &NSPasteboard,
108 ) -> Option<Retained<Self>>;
109
110 #[cfg(feature = "NSPasteboard")]
111 #[unsafe(method(writeToPasteboard:))]
112 #[unsafe(method_family = none)]
113 pub fn writeToPasteboard(&self, pasteboard: &NSPasteboard);
114
115 #[unsafe(method(play))]
116 #[unsafe(method_family = none)]
117 pub fn play(&self) -> bool;
118
119 #[unsafe(method(pause))]
120 #[unsafe(method_family = none)]
121 pub fn pause(&self) -> bool;
122
123 #[unsafe(method(resume))]
124 #[unsafe(method_family = none)]
125 pub fn resume(&self) -> bool;
126
127 #[unsafe(method(stop))]
128 #[unsafe(method_family = none)]
129 pub fn stop(&self) -> bool;
130
131 #[unsafe(method(isPlaying))]
132 #[unsafe(method_family = none)]
133 pub fn isPlaying(&self) -> bool;
134
135 #[unsafe(method(delegate))]
136 #[unsafe(method_family = none)]
137 pub fn delegate(
138 &self,
139 mtm: MainThreadMarker,
140 ) -> Option<Retained<ProtocolObject<dyn NSSoundDelegate>>>;
141
142 #[unsafe(method(setDelegate:))]
146 #[unsafe(method_family = none)]
147 pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSSoundDelegate>>);
148
149 #[unsafe(method(duration))]
150 #[unsafe(method_family = none)]
151 pub fn duration(&self) -> NSTimeInterval;
152
153 #[unsafe(method(volume))]
154 #[unsafe(method_family = none)]
155 pub fn volume(&self) -> c_float;
156
157 #[unsafe(method(setVolume:))]
159 #[unsafe(method_family = none)]
160 pub fn setVolume(&self, volume: c_float);
161
162 #[unsafe(method(currentTime))]
163 #[unsafe(method_family = none)]
164 pub fn currentTime(&self) -> NSTimeInterval;
165
166 #[unsafe(method(setCurrentTime:))]
168 #[unsafe(method_family = none)]
169 pub fn setCurrentTime(&self, current_time: NSTimeInterval);
170
171 #[unsafe(method(loops))]
172 #[unsafe(method_family = none)]
173 pub fn loops(&self) -> bool;
174
175 #[unsafe(method(setLoops:))]
177 #[unsafe(method_family = none)]
178 pub fn setLoops(&self, loops: bool);
179
180 #[unsafe(method(playbackDeviceIdentifier))]
181 #[unsafe(method_family = none)]
182 pub fn playbackDeviceIdentifier(&self)
183 -> Option<Retained<NSSoundPlaybackDeviceIdentifier>>;
184
185 #[unsafe(method(setPlaybackDeviceIdentifier:))]
189 #[unsafe(method_family = none)]
190 pub fn setPlaybackDeviceIdentifier(
191 &self,
192 playback_device_identifier: Option<&NSSoundPlaybackDeviceIdentifier>,
193 );
194
195 #[deprecated]
200 #[unsafe(method(setChannelMapping:))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn setChannelMapping(&self, channel_mapping: Option<&NSArray>);
203
204 #[deprecated]
205 #[unsafe(method(channelMapping))]
206 #[unsafe(method_family = none)]
207 pub fn channelMapping(&self) -> Option<Retained<NSArray>>;
208 );
209}
210
211impl NSSound {
213 extern_methods!(
214 #[unsafe(method(init))]
215 #[unsafe(method_family = init)]
216 pub fn init(this: Allocated<Self>) -> Retained<Self>;
217
218 #[unsafe(method(new))]
219 #[unsafe(method_family = new)]
220 pub fn new() -> Retained<Self>;
221 );
222}
223
224impl DefaultRetained for NSSound {
225 #[inline]
226 fn default_retained() -> Retained<Self> {
227 Self::new()
228 }
229}
230
231impl NSSound {
233 extern_methods!(
234 #[deprecated]
235 #[unsafe(method(soundUnfilteredFileTypes))]
236 #[unsafe(method_family = none)]
237 pub fn soundUnfilteredFileTypes() -> Option<Retained<NSArray>>;
238
239 #[deprecated]
240 #[unsafe(method(soundUnfilteredPasteboardTypes))]
241 #[unsafe(method_family = none)]
242 pub fn soundUnfilteredPasteboardTypes() -> Option<Retained<NSArray>>;
243 );
244}
245
246extern_protocol!(
247 pub unsafe trait NSSoundDelegate: NSObjectProtocol + MainThreadOnly {
249 #[optional]
250 #[unsafe(method(sound:didFinishPlaying:))]
251 #[unsafe(method_family = none)]
252 fn sound_didFinishPlaying(&self, sound: &NSSound, flag: bool);
253 }
254);
255
256mod private_NSBundleSoundExtensions {
257 pub trait Sealed {}
258}
259
260pub unsafe trait NSBundleSoundExtensions:
262 ClassType + Sized + private_NSBundleSoundExtensions::Sealed
263{
264 extern_methods!(
265 #[unsafe(method(pathForSoundResource:))]
266 #[unsafe(method_family = none)]
267 fn pathForSoundResource(&self, name: &NSSoundName) -> Option<Retained<NSString>>;
268 );
269}
270
271impl private_NSBundleSoundExtensions::Sealed for NSBundle {}
272unsafe impl NSBundleSoundExtensions for NSBundle {}