comparison dstep/appkit/NSSound.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents
children b9de51448c6b
comparison
equal deleted inserted replaced
15:7ff919f595d5 16:19885b43130e
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Sep 24, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.appkit.NSSound;
8
9 import dstep.appkit.AppKitDefines;
10 import dstep.appkit.NSPasteboard;
11 import dstep.foundation.NSArray;
12 import dstep.foundation.NSBundle;
13 import dstep.foundation.NSCoder;
14 import dstep.foundation.NSData;
15 import dstep.foundation.NSDate;
16 import dstep.foundation.NSObject;
17 import dstep.foundation.NSString;
18 import dstep.foundation.NSURL;
19 import dstep.foundation.NSZone;
20 import dstep.objc.bridge.Bridge;
21 import dstep.objc.objc;
22
23 import bindings = dstep.appkit.NSSound_bindings;
24
25 private
26 {
27 NSString NSSoundPboardType_;
28 }
29
30 NSString NSSoundPboardType ()
31 {
32 if (NSSoundPboardType_)
33 return NSSoundPboardType_;
34
35 return NSSoundPboardType_ = new NSString(bindings.NSSoundPboardType);
36 }
37
38 class NSSound : NSObject, INSCopying, INSCoding
39 {
40 mixin (ObjcWrap);
41
42 this (NSCoder aDecoder)
43 {
44 super(typeof(this).alloc.initWithCoder(aDecoder).objcObject);
45 }
46
47 void encodeWithCoder (NSCoder aCoder)
48 {
49 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
50 }
51
52 typeof(this) initWithCoder (NSCoder aDecoder)
53 {
54 return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder);
55 }
56
57 typeof(this) copyWithZone (NSZone* zone)
58 {
59 return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone);
60 }
61
62 static Object soundNamed (NSString name)
63 {
64 return invokeObjcSelfClass!(Object, "soundNamed:", NSString)(name);
65 }
66
67 NSSound initWithContentsOfURL (NSURL url, bool byRef)
68 {
69 id result = invokeObjcSelf!(id, "initWithContentsOfURL:byReference:", NSURL, bool)(url, byRef);
70 return result is this.objcObject ? this : (result !is null ? new NSSound(result) : null);
71 }
72
73 this (NSURL url, bool byRef)
74 {
75 super(NSSound.alloc.initWithContentsOfURL(url, byRef).objcObject);
76 }
77
78 NSSound initWithContentsOfFile (NSString path, bool byRef)
79 {
80 id result = invokeObjcSelf!(id, "initWithContentsOfFile:byReference:", NSString, bool)(path, byRef);
81 return result is this.objcObject ? this : (result !is null ? new NSSound(result) : null);
82 }
83
84 this (NSString path, bool byRef)
85 {
86 super(NSSound.alloc.initWithContentsOfFile(path, byRef).objcObject);
87 }
88
89 NSSound initWithData (NSData data)
90 {
91 id result = invokeObjcSelf!(id, "initWithData:", NSData)(data);
92 return result is this.objcObject ? this : (result !is null ? new NSSound(result) : null);
93 }
94
95 this (NSData data)
96 {
97 super(NSSound.alloc.initWithData(data).objcObject);
98 }
99
100 bool setName (NSString string)
101 {
102 return invokeObjcSelf!(bool, "setName:", NSString)(string);
103 }
104
105 NSString name ()
106 {
107 return invokeObjcSelf!(NSString, "name");
108 }
109
110 static bool canInitWithPasteboard (NSPasteboard pasteboard)
111 {
112 return invokeObjcSelfClass!(bool, "canInitWithPasteboard:", NSPasteboard)(pasteboard);
113 }
114
115 static NSArray soundUnfilteredTypes ()
116 {
117 return invokeObjcSelfClass!(NSArray, "soundUnfilteredTypes");
118 }
119
120 NSSound initWithPasteboard (NSPasteboard pasteboard)
121 {
122 id result = invokeObjcSelf!(id, "initWithPasteboard:", NSPasteboard)(pasteboard);
123 return result is this.objcObject ? this : (result !is null ? new NSSound(result) : null);
124 }
125
126 this (NSPasteboard pasteboard)
127 {
128 super(NSSound.alloc.initWithPasteboard(pasteboard).objcObject);
129 }
130
131 void writeToPasteboard (NSPasteboard pasteboard)
132 {
133 return invokeObjcSelf!(void, "writeToPasteboard:", NSPasteboard)(pasteboard);
134 }
135
136 bool play ()
137 {
138 return invokeObjcSelf!(bool, "play");
139 }
140
141 bool pause ()
142 {
143 return invokeObjcSelf!(bool, "pause");
144 }
145
146 bool resume ()
147 {
148 return invokeObjcSelf!(bool, "resume");
149 }
150
151 bool stop ()
152 {
153 return invokeObjcSelf!(bool, "stop");
154 }
155
156 bool isPlaying ()
157 {
158 return invokeObjcSelf!(bool, "isPlaying");
159 }
160
161 Object delegate_ ()
162 {
163 return invokeObjcSelf!(Object, "delegate");
164 }
165
166 void setDelegate (Object aDelegate)
167 {
168 return invokeObjcSelf!(void, "setDelegate:", Object)(aDelegate);
169 }
170
171 double duration ()
172 {
173 return invokeObjcSelf!(double, "duration");
174 }
175
176 void setVolume (float volume)
177 {
178 return invokeObjcSelf!(void, "setVolume:", float)(volume);
179 }
180
181 float volume ()
182 {
183 return invokeObjcSelf!(float, "volume");
184 }
185
186 double currentTime ()
187 {
188 return invokeObjcSelf!(double, "currentTime");
189 }
190
191 void setCurrentTime (double seconds)
192 {
193 return invokeObjcSelf!(void, "setCurrentTime:", double)(seconds);
194 }
195
196 void setLoops (bool val)
197 {
198 return invokeObjcSelf!(void, "setLoops:", bool)(val);
199 }
200
201 bool loops ()
202 {
203 return invokeObjcSelf!(bool, "loops");
204 }
205
206 void setPlaybackDeviceIdentifier (NSString deviceUID)
207 {
208 return invokeObjcSelf!(void, "setPlaybackDeviceIdentifier:", NSString)(deviceUID);
209 }
210
211 NSString playbackDeviceIdentifier ()
212 {
213 return invokeObjcSelf!(NSString, "playbackDeviceIdentifier");
214 }
215
216 void setChannelMapping (NSArray channelMapping)
217 {
218 return invokeObjcSelf!(void, "setChannelMapping:", NSArray)(channelMapping);
219 }
220
221 NSArray channelMapping ()
222 {
223 return invokeObjcSelf!(NSArray, "channelMapping");
224 }
225
226 }
227
228 const TNSBundleSoundExtensions = `
229
230 NSString pathForSoundResource (NSString name)
231 {
232 return invokeObjcSelf!(NSString, "pathForSoundResource:", NSString)(name);
233 }
234
235 //mixin ObjcBindMethod!(pathForSoundResource, "pathForSoundResource:");
236
237 `;
238
239 const TNSSoundDelegateMethods = `
240
241 void sound (NSSound sound, bool aBool)
242 {
243 return invokeObjcSelf!(void, "sound:didFinishPlaying:", NSSound, bool)(sound, aBool);
244 }
245
246 //mixin ObjcBindMethod!(sound, "sound:didFinishPlaying:");
247
248 `;
249