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 unsafe fn soundNamed(name: &NSSoundName) -> Option<Retained<NSSound>>;
64
65 #[unsafe(method(initWithContentsOfURL:byReference:))]
66 #[unsafe(method_family = init)]
67 pub unsafe 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 unsafe 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 unsafe fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;
84
85 #[unsafe(method(setName:))]
86 #[unsafe(method_family = none)]
87 pub unsafe fn setName(&self, string: Option<&NSSoundName>) -> bool;
88
89 #[unsafe(method(name))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn name(&self) -> Option<Retained<NSSoundName>>;
92
93 #[cfg(feature = "NSPasteboard")]
94 #[unsafe(method(canInitWithPasteboard:))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn canInitWithPasteboard(pasteboard: &NSPasteboard) -> bool;
97
98 #[unsafe(method(soundUnfilteredTypes))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn soundUnfilteredTypes() -> Retained<NSArray<NSString>>;
101
102 #[cfg(feature = "NSPasteboard")]
103 #[unsafe(method(initWithPasteboard:))]
104 #[unsafe(method_family = init)]
105 pub unsafe 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 unsafe fn writeToPasteboard(&self, pasteboard: &NSPasteboard);
114
115 #[unsafe(method(play))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn play(&self) -> bool;
118
119 #[unsafe(method(pause))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn pause(&self) -> bool;
122
123 #[unsafe(method(resume))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn resume(&self) -> bool;
126
127 #[unsafe(method(stop))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn stop(&self) -> bool;
130
131 #[unsafe(method(isPlaying))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn isPlaying(&self) -> bool;
134
135 #[unsafe(method(delegate))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn delegate(
138 &self,
139 mtm: MainThreadMarker,
140 ) -> Option<Retained<ProtocolObject<dyn NSSoundDelegate>>>;
141
142 #[unsafe(method(setDelegate:))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSSoundDelegate>>);
147
148 #[unsafe(method(duration))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn duration(&self) -> NSTimeInterval;
151
152 #[unsafe(method(volume))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn volume(&self) -> c_float;
155
156 #[unsafe(method(setVolume:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn setVolume(&self, volume: c_float);
160
161 #[unsafe(method(currentTime))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn currentTime(&self) -> NSTimeInterval;
164
165 #[unsafe(method(setCurrentTime:))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn setCurrentTime(&self, current_time: NSTimeInterval);
169
170 #[unsafe(method(loops))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn loops(&self) -> bool;
173
174 #[unsafe(method(setLoops:))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn setLoops(&self, loops: bool);
178
179 #[unsafe(method(playbackDeviceIdentifier))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn playbackDeviceIdentifier(
182 &self,
183 ) -> Option<Retained<NSSoundPlaybackDeviceIdentifier>>;
184
185 #[unsafe(method(setPlaybackDeviceIdentifier:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn setPlaybackDeviceIdentifier(
189 &self,
190 playback_device_identifier: Option<&NSSoundPlaybackDeviceIdentifier>,
191 );
192
193 #[deprecated]
194 #[unsafe(method(setChannelMapping:))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn setChannelMapping(&self, channel_mapping: Option<&NSArray>);
197
198 #[deprecated]
199 #[unsafe(method(channelMapping))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn channelMapping(&self) -> Option<Retained<NSArray>>;
202 );
203}
204
205impl NSSound {
207 extern_methods!(
208 #[unsafe(method(init))]
209 #[unsafe(method_family = init)]
210 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
211
212 #[unsafe(method(new))]
213 #[unsafe(method_family = new)]
214 pub unsafe fn new() -> Retained<Self>;
215 );
216}
217
218impl NSSound {
220 extern_methods!(
221 #[deprecated]
222 #[unsafe(method(soundUnfilteredFileTypes))]
223 #[unsafe(method_family = none)]
224 pub unsafe fn soundUnfilteredFileTypes() -> Option<Retained<NSArray>>;
225
226 #[deprecated]
227 #[unsafe(method(soundUnfilteredPasteboardTypes))]
228 #[unsafe(method_family = none)]
229 pub unsafe fn soundUnfilteredPasteboardTypes() -> Option<Retained<NSArray>>;
230 );
231}
232
233extern_protocol!(
234 pub unsafe trait NSSoundDelegate: NSObjectProtocol + MainThreadOnly {
236 #[optional]
237 #[unsafe(method(sound:didFinishPlaying:))]
238 #[unsafe(method_family = none)]
239 unsafe fn sound_didFinishPlaying(&self, sound: &NSSound, flag: bool);
240 }
241);
242
243mod private_NSBundleSoundExtensions {
244 pub trait Sealed {}
245}
246
247pub unsafe trait NSBundleSoundExtensions:
249 ClassType + Sized + private_NSBundleSoundExtensions::Sealed
250{
251 extern_methods!(
252 #[unsafe(method(pathForSoundResource:))]
253 #[unsafe(method_family = none)]
254 unsafe fn pathForSoundResource(&self, name: &NSSoundName) -> Option<Retained<NSString>>;
255 );
256}
257
258impl private_NSBundleSoundExtensions::Sealed for NSBundle {}
259unsafe impl NSBundleSoundExtensions for NSBundle {}