• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: problems loading a sound with NSSound
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems loading a sound with NSSound


  • Subject: Re: problems loading a sound with NSSound
  • From: "James W. Walker" <email@hidden>
  • Date: Sun, 7 Mar 2010 22:08:49 -0800

On Mar 7, 2010, at 8:26 PM, Jonathan Chacón wrote:

> I added a sound file to the resources of my project ( logoSound.AIF )
>
> I use this function to load the resource:
>
> -(NSSound*) getSound:(NSString *) sndValue {
> 	NSBundle *bundle = [ NSBundle bundleForClass: [ self class ] ];
> 	NSString *sndName = [ bundle pathForResource: sndValue ofType: @"aif" ];
> 	NSSound *sound = [ [ NSSound alloc ]
> 					  initWithContentsOfFile: sndName ];
> 	return sound;
> } // getSound
>
>
> I do this to load the sound file:
>
> NSSound *logoSound = [self getSound: @"logoSound"];
>
> I try:
> [logoSound play];
>
> but the sound doesn't play


Did you use the debugger to verify that logoSound is not nil when you try to play it?

When I tried using NSSound, nobody was able to tell me how to make it work reliably.  I ended up using SystemSoundPlay instead (see TN 2102).

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >problems loading a sound with NSSound (From: "Jonathan Chacón" <email@hidden>)

  • Prev by Date: Re: NSDocumentController subclass not instantiated first?
  • Next by Date: Re: cocoa-dev vs. Apple's dev forums?
  • Previous by thread: problems loading a sound with NSSound
  • Next by thread: Re: problems loading a sound with NSSound
  • Index(es):
    • Date
    • Thread