nssound

How can I add sound to a button in iOS?

微笑、不失礼 提交于 2019-12-31 10:53:09
问题 I would like to make a sound play when a button is pressed. Also, there is more than one sound. I am using Xcode 4.4.1 and Storyboard. In the .h file { IBOutlet UIButton *playSound; } 回答1: I thought it would be fun to write this type example so I wrote it. It demonstrates how to play different random sound when button is pressed: -(IBAction)buttonPressedWithSound:(id)sender { int randomSoundNumber = arc4random() % 4; //random number from 0 to 3 NSLog(@"random sound number = %i",

NSSound not working properly

倾然丶 夕夏残阳落幕 提交于 2019-12-25 01:16:55
问题 I am using Cocoa on Mac 10.6. I am trying to have a metronome click out the time but when I run the code only the first two sounds are played then it is quiet till the end when a sound plays again. If I replace the [player play] statements with NSBeep() it works fine. Any suggestions? #import <Cocoa/Cocoa.h> @interface Metronome : NSObject { NSInteger timeSig; NSInteger noteValue; NSInteger bpm; NSUInteger beatNumber; CGFloat duration; NSSound *tickPlayer; NSSound *tockPlayer; } @property

How to play a mp3 file from within the Resources folder of my application?

核能气质少年 提交于 2019-12-24 08:47:44
问题 I am making an app that will play sound on events but I can't figure out how to access files from the ressources folder of the Application. Here is what I'm doing : NSSound *player = [[NSSound alloc] initWithContentsOfFile:@"Sound.mp3"] byReference:NO]; [player play]; But it's not working at all. If I put a full length path it will work but I need another way because someone might put my app in an other place than the Application folder. 回答1: You need to use the NSBundle class with the

What's the SIMPLEST way to play a sound clip in an iPhone app?

纵饮孤独 提交于 2019-12-04 14:05:50
问题 I want to be able to play a sound clip in an iPhone OS app. I've seen info on both NSSound as well as AVFoundation as being means for getting sound clips played on an iPhone OS device, but I'm still not clear on the subject and could use some help. No need to spell it out for me step-by-step in actual code, but if someone could give me a hint as to the general direction (i.e. which classes I should be focusing on) in which I should start moving I'll fill in the blanks myself. So, what's the

What's the SIMPLEST way to play a sound clip in an iPhone app?

只愿长相守 提交于 2019-12-03 09:48:52
I want to be able to play a sound clip in an iPhone OS app. I've seen info on both NSSound as well as AVFoundation as being means for getting sound clips played on an iPhone OS device, but I'm still not clear on the subject and could use some help. No need to spell it out for me step-by-step in actual code, but if someone could give me a hint as to the general direction (i.e. which classes I should be focusing on) in which I should start moving I'll fill in the blanks myself. So, what's the SIMPLEST way to play a sound clip in an iPhone app? Apple has an article on this subject, see: this link

How can I add sound to a button in iOS?

偶尔善良 提交于 2019-12-02 21:24:26
I would like to make a sound play when a button is pressed. Also, there is more than one sound. I am using Xcode 4.4.1 and Storyboard. In the .h file { IBOutlet UIButton *playSound; } I thought it would be fun to write this type example so I wrote it. It demonstrates how to play different random sound when button is pressed: -(IBAction)buttonPressedWithSound:(id)sender { int randomSoundNumber = arc4random() % 4; //random number from 0 to 3 NSLog(@"random sound number = %i", randomSoundNumber); NSString *effectTitle; switch (randomSoundNumber) { case 0: effectTitle = @"sound1"; break; case 1:

sound picker / list of system sounds [duplicate]

风流意气都作罢 提交于 2019-11-29 08:18:45
This question already has an answer here: Playing system sound without importing your own 9 answers Okay. I was looking for a neat way to list system sounds that are played with [NSSound soundNamed: ] - and to me it seemed that API does not have list of available sounds. I also searched this with google and found some pretty old and partially already deprecated sources. If application should have a soundpicker - what would be a best way to get list of system provided sounds? This is my implementation. NSSound (systemSounds.h): #import <AppKit/AppKit.h> @interface NSSound (systemSounds) +

Sound picker / List of system sounds on macOS [duplicate]

独自空忆成欢 提交于 2019-11-28 01:23:55
问题 This question already has answers here : Playing system sound without importing your own (9 answers) Closed 6 years ago . Okay. I was looking for a neat way to list system sounds that are played with [NSSound soundNamed: ] - and to me it seemed that API does not have list of available sounds. I also searched this with google and found some pretty old and partially already deprecated sources. If application should have a soundpicker - what would be a best way to get list of system provided