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
29unsafe impl NSCoding for NSSound {}
30
31unsafe impl NSCopying for NSSound {}
32
33unsafe impl CopyingHelper for NSSound {
34 type Result = Self;
35}
36
37unsafe impl NSObjectProtocol for NSSound {}
38
39#[cfg(feature = "NSPasteboard")]
40unsafe impl NSPasteboardReading for NSSound {}
41
42#[cfg(feature = "NSPasteboard")]
43unsafe impl NSPasteboardWriting for NSSound {}
44
45unsafe impl NSSecureCoding for NSSound {}
46
47impl NSSound {
48 extern_methods!(
49 #[unsafe(method(soundNamed:))]
50 #[unsafe(method_family = none)]
51 pub unsafe fn soundNamed(name: &NSSoundName) -> Option<Retained<NSSound>>;
52
53 #[unsafe(method(initWithContentsOfURL:byReference:))]
54 #[unsafe(method_family = init)]
55 pub unsafe fn initWithContentsOfURL_byReference(
56 this: Allocated<Self>,
57 url: &NSURL,
58 by_ref: bool,
59 ) -> Option<Retained<Self>>;
60
61 #[unsafe(method(initWithContentsOfFile:byReference:))]
62 #[unsafe(method_family = init)]
63 pub unsafe fn initWithContentsOfFile_byReference(
64 this: Allocated<Self>,
65 path: &NSString,
66 by_ref: bool,
67 ) -> Option<Retained<Self>>;
68
69 #[unsafe(method(initWithData:))]
70 #[unsafe(method_family = init)]
71 pub unsafe fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;
72
73 #[unsafe(method(setName:))]
74 #[unsafe(method_family = none)]
75 pub unsafe fn setName(&self, string: Option<&NSSoundName>) -> bool;
76
77 #[unsafe(method(name))]
78 #[unsafe(method_family = none)]
79 pub unsafe fn name(&self) -> Option<Retained<NSSoundName>>;
80
81 #[cfg(feature = "NSPasteboard")]
82 #[unsafe(method(canInitWithPasteboard:))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn canInitWithPasteboard(pasteboard: &NSPasteboard) -> bool;
85
86 #[unsafe(method(soundUnfilteredTypes))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn soundUnfilteredTypes() -> Retained<NSArray<NSString>>;
89
90 #[cfg(feature = "NSPasteboard")]
91 #[unsafe(method(initWithPasteboard:))]
92 #[unsafe(method_family = init)]
93 pub unsafe fn initWithPasteboard(
94 this: Allocated<Self>,
95 pasteboard: &NSPasteboard,
96 ) -> Option<Retained<Self>>;
97
98 #[cfg(feature = "NSPasteboard")]
99 #[unsafe(method(writeToPasteboard:))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn writeToPasteboard(&self, pasteboard: &NSPasteboard);
102
103 #[unsafe(method(play))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn play(&self) -> bool;
106
107 #[unsafe(method(pause))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn pause(&self) -> bool;
110
111 #[unsafe(method(resume))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn resume(&self) -> bool;
114
115 #[unsafe(method(stop))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn stop(&self) -> bool;
118
119 #[unsafe(method(isPlaying))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn isPlaying(&self) -> bool;
122
123 #[unsafe(method(delegate))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn delegate(
126 &self,
127 mtm: MainThreadMarker,
128 ) -> Option<Retained<ProtocolObject<dyn NSSoundDelegate>>>;
129
130 #[unsafe(method(setDelegate:))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSSoundDelegate>>);
135
136 #[unsafe(method(duration))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn duration(&self) -> NSTimeInterval;
139
140 #[unsafe(method(volume))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn volume(&self) -> c_float;
143
144 #[unsafe(method(setVolume:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn setVolume(&self, volume: c_float);
148
149 #[unsafe(method(currentTime))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn currentTime(&self) -> NSTimeInterval;
152
153 #[unsafe(method(setCurrentTime:))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn setCurrentTime(&self, current_time: NSTimeInterval);
157
158 #[unsafe(method(loops))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn loops(&self) -> bool;
161
162 #[unsafe(method(setLoops:))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn setLoops(&self, loops: bool);
166
167 #[unsafe(method(playbackDeviceIdentifier))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn playbackDeviceIdentifier(
170 &self,
171 ) -> Option<Retained<NSSoundPlaybackDeviceIdentifier>>;
172
173 #[unsafe(method(setPlaybackDeviceIdentifier:))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn setPlaybackDeviceIdentifier(
177 &self,
178 playback_device_identifier: Option<&NSSoundPlaybackDeviceIdentifier>,
179 );
180
181 #[deprecated]
182 #[unsafe(method(setChannelMapping:))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn setChannelMapping(&self, channel_mapping: Option<&NSArray>);
185
186 #[deprecated]
187 #[unsafe(method(channelMapping))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn channelMapping(&self) -> Option<Retained<NSArray>>;
190 );
191}
192
193impl NSSound {
195 extern_methods!(
196 #[unsafe(method(init))]
197 #[unsafe(method_family = init)]
198 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
199
200 #[unsafe(method(new))]
201 #[unsafe(method_family = new)]
202 pub unsafe fn new() -> Retained<Self>;
203 );
204}
205
206impl NSSound {
208 extern_methods!(
209 #[deprecated]
210 #[unsafe(method(soundUnfilteredFileTypes))]
211 #[unsafe(method_family = none)]
212 pub unsafe fn soundUnfilteredFileTypes() -> Option<Retained<NSArray>>;
213
214 #[deprecated]
215 #[unsafe(method(soundUnfilteredPasteboardTypes))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn soundUnfilteredPasteboardTypes() -> Option<Retained<NSArray>>;
218 );
219}
220
221extern_protocol!(
222 pub unsafe trait NSSoundDelegate: NSObjectProtocol + MainThreadOnly {
224 #[optional]
225 #[unsafe(method(sound:didFinishPlaying:))]
226 #[unsafe(method_family = none)]
227 unsafe fn sound_didFinishPlaying(&self, sound: &NSSound, flag: bool);
228 }
229);
230
231mod private_NSBundleSoundExtensions {
232 pub trait Sealed {}
233}
234
235pub unsafe trait NSBundleSoundExtensions:
237 ClassType + Sized + private_NSBundleSoundExtensions::Sealed
238{
239 extern_methods!(
240 #[unsafe(method(pathForSoundResource:))]
241 #[unsafe(method_family = none)]
242 unsafe fn pathForSoundResource(&self, name: &NSSoundName) -> Option<Retained<NSString>>;
243 );
244}
245
246impl private_NSBundleSoundExtensions::Sealed for NSBundle {}
247unsafe impl NSBundleSoundExtensions for NSBundle {}