• 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: NSSound + NSBundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSound + NSBundle


  • Subject: Re: NSSound + NSBundle
  • From: Roelof Roos <email@hidden>
  • Date: Sat, 21 Apr 2007 19:14:10 -0700

Your code is accessing files inside the bundle of your app. The root of your harddrive is not part of your apps bundle. If you want to access files that are not in the bundle, you should not use NSBundle.

I think this will work:

song1 = [[NSSound alloc] initWithContentsOfFile:@"/gun.mp3"
                                    byReference:YES];

Hopes this helps,

Roelof

The errors that i am getting are:

[Session started at 2007-04-22 11:19:17 +0930.]
2007-04-22 11:20:21.817 NSSound[535] *** -[NSCFString stringValue]:
selector not recognized [self = 0x306240]
2007-04-22 11:20:21.899 NSSound[535] *** -[NSCFString stringValue]:
selector not recognized [self = 0x306240]

The path i am using is an mp3 file in the root of my harddrive, "/gun.mp3"
The program does play mp3 files, as the three songs that i have
working are mp3.

On 22/04/07, Jake Sprouse <email@hidden> wrote:
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/Classes/NSSound_Class/Reference/Reference.html

"The NSSound class provides a simple interface for loading and
playing AIFF, WAV, and NeXT ".snd" files. NSSound supports 16-bit,
mono and stereo, 44.1KHz and 22.05KHz data."

Could this have something to do with the errors you're seeing?  BTW,
it's very helpful to post the errors you're trying to deal with.



On Apr 21, 2007, at 6:04 PM, Tim Simon wrote:

 I have a program that plays sounds that are added into the project.
 Whilst this works fine, i want to be able to select a song that is in
 any directory on my Mac, without adding it specifically to the project
 itself.
 To initialize the first song, this code is used:

 >       song1 = [[NSSound alloc] initWithContentsOfFile:[thisBundle
 > pathForResource:@"sound1" ofType:@"mp3"] byReference:YES];

I tried using a NSTextField to allow the user to enter the path for the sound, and then use

       song1 = [[NSSound alloc] initWithContentsOfFile:[thisBundle
 pathForResource:[NSTextField stringValue] ofType:@"mp3"]
 byReference:YES];

 to play, but this comes up with errors. I belive that it is something
 to do with the NSBundle that is used, but im not sure how to actually
 change it so it works.

 Cheers, Tim
 _______________________________________________

 Cocoa-dev mailing list (email@hidden)

 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:
 40jakesprouse.net

This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >NSSound + NSBundle (From: "Tim Simon" <email@hidden>)
 >Re: NSSound + NSBundle (From: Jake Sprouse <email@hidden>)
 >Re: NSSound + NSBundle (From: "Tim Simon" <email@hidden>)

  • Prev by Date: Re: NSSound + NSBundle
  • Next by Date: Re: Undo Manager (hac)
  • Previous by thread: Re: NSSound + NSBundle
  • Next by thread: Re: NSSound + NSBundle
  • Index(es):
    • Date
    • Thread