Mercurial > projects > dstep
view 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 |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Sep 24, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.appkit.NSSound; import dstep.appkit.AppKitDefines; import dstep.appkit.NSPasteboard; import dstep.foundation.NSArray; import dstep.foundation.NSBundle; import dstep.foundation.NSCoder; import dstep.foundation.NSData; import dstep.foundation.NSDate; import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.foundation.NSURL; import dstep.foundation.NSZone; import dstep.objc.bridge.Bridge; import dstep.objc.objc; import bindings = dstep.appkit.NSSound_bindings; private { NSString NSSoundPboardType_; } NSString NSSoundPboardType () { if (NSSoundPboardType_) return NSSoundPboardType_; return NSSoundPboardType_ = new NSString(bindings.NSSoundPboardType); } class NSSound : NSObject, INSCopying, INSCoding { mixin (ObjcWrap); this (NSCoder aDecoder) { super(typeof(this).alloc.initWithCoder(aDecoder).objcObject); } void encodeWithCoder (NSCoder aCoder) { return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); } typeof(this) initWithCoder (NSCoder aDecoder) { return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder); } typeof(this) copyWithZone (NSZone* zone) { return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone); } static Object soundNamed (NSString name) { return invokeObjcSelfClass!(Object, "soundNamed:", NSString)(name); } NSSound initWithContentsOfURL (NSURL url, bool byRef) { id result = invokeObjcSelf!(id, "initWithContentsOfURL:byReference:", NSURL, bool)(url, byRef); return result is this.objcObject ? this : (result !is null ? new NSSound(result) : null); } this (NSURL url, bool byRef) { super(NSSound.alloc.initWithContentsOfURL(url, byRef).objcObject); } NSSound initWithContentsOfFile (NSString path, bool byRef) { id result = invokeObjcSelf!(id, "initWithContentsOfFile:byReference:", NSString, bool)(path, byRef); return result is this.objcObject ? this : (result !is null ? new NSSound(result) : null); } this (NSString path, bool byRef) { super(NSSound.alloc.initWithContentsOfFile(path, byRef).objcObject); } NSSound initWithData (NSData data) { id result = invokeObjcSelf!(id, "initWithData:", NSData)(data); return result is this.objcObject ? this : (result !is null ? new NSSound(result) : null); } this (NSData data) { super(NSSound.alloc.initWithData(data).objcObject); } bool setName (NSString string) { return invokeObjcSelf!(bool, "setName:", NSString)(string); } NSString name () { return invokeObjcSelf!(NSString, "name"); } static bool canInitWithPasteboard (NSPasteboard pasteboard) { return invokeObjcSelfClass!(bool, "canInitWithPasteboard:", NSPasteboard)(pasteboard); } static NSArray soundUnfilteredTypes () { return invokeObjcSelfClass!(NSArray, "soundUnfilteredTypes"); } NSSound initWithPasteboard (NSPasteboard pasteboard) { id result = invokeObjcSelf!(id, "initWithPasteboard:", NSPasteboard)(pasteboard); return result is this.objcObject ? this : (result !is null ? new NSSound(result) : null); } this (NSPasteboard pasteboard) { super(NSSound.alloc.initWithPasteboard(pasteboard).objcObject); } void writeToPasteboard (NSPasteboard pasteboard) { return invokeObjcSelf!(void, "writeToPasteboard:", NSPasteboard)(pasteboard); } bool play () { return invokeObjcSelf!(bool, "play"); } bool pause () { return invokeObjcSelf!(bool, "pause"); } bool resume () { return invokeObjcSelf!(bool, "resume"); } bool stop () { return invokeObjcSelf!(bool, "stop"); } bool isPlaying () { return invokeObjcSelf!(bool, "isPlaying"); } Object delegate_ () { return invokeObjcSelf!(Object, "delegate"); } void setDelegate (Object aDelegate) { return invokeObjcSelf!(void, "setDelegate:", Object)(aDelegate); } double duration () { return invokeObjcSelf!(double, "duration"); } void setVolume (float volume) { return invokeObjcSelf!(void, "setVolume:", float)(volume); } float volume () { return invokeObjcSelf!(float, "volume"); } double currentTime () { return invokeObjcSelf!(double, "currentTime"); } void setCurrentTime (double seconds) { return invokeObjcSelf!(void, "setCurrentTime:", double)(seconds); } void setLoops (bool val) { return invokeObjcSelf!(void, "setLoops:", bool)(val); } bool loops () { return invokeObjcSelf!(bool, "loops"); } void setPlaybackDeviceIdentifier (NSString deviceUID) { return invokeObjcSelf!(void, "setPlaybackDeviceIdentifier:", NSString)(deviceUID); } NSString playbackDeviceIdentifier () { return invokeObjcSelf!(NSString, "playbackDeviceIdentifier"); } void setChannelMapping (NSArray channelMapping) { return invokeObjcSelf!(void, "setChannelMapping:", NSArray)(channelMapping); } NSArray channelMapping () { return invokeObjcSelf!(NSArray, "channelMapping"); } } const TNSBundleSoundExtensions = ` NSString pathForSoundResource (NSString name) { return invokeObjcSelf!(NSString, "pathForSoundResource:", NSString)(name); } //mixin ObjcBindMethod!(pathForSoundResource, "pathForSoundResource:"); `; const TNSSoundDelegateMethods = ` void sound (NSSound sound, bool aBool) { return invokeObjcSelf!(void, "sound:didFinishPlaying:", NSSound, bool)(sound, aBool); } //mixin ObjcBindMethod!(sound, "sound:didFinishPlaying:"); `;