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

NSSound + NSBundle


  • Subject: NSSound + NSBundle
  • From: "Tim Simon" <email@hidden>
  • Date: Sun, 22 Apr 2007 10:34:09 +0930

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSSound + NSBundle
      • From: j o a r <email@hidden>
    • Re: NSSound + NSBundle
      • From: Jake Sprouse <email@hidden>
  • Prev by Date: Correct way to create a subview at runtime
  • Next by Date: Re: NSSound + NSBundle
  • Previous by thread: Re: Correct way to create a subview at runtime [Solved]
  • Next by thread: Re: NSSound + NSBundle
  • Index(es):
    • Date
    • Thread