什么代码可以让我在iPhone上产生标准的哔声?你如何使iPhone哔声?
1
A
回答
3
那它取决于你想要什么样的声音。
以下介绍如何使用AVFoundation音频框架播放声音。
#import <UIKit/UIKit.h>
@class AVAudioPlayer;
@interface AudioPlayer : UIViewController {
IBOutlet UIButton *playButton;
IBOutlet UIButton *stopButton;
AVAudioPlayer *audioPlayer;
}
@property (nonatomic, retain) IBOutlet UIButton *playButton;
@property (nonatomic, retain) IBOutlet UIButton *stopButton;
@property (nonatomic, retain) AVAudioPlayer *audioPlayer;
-(IBAction)play;
-(IBAction)stop;
@end
- (void)viewDidLoad {
[super viewDidLoad];
// Get the file path to the song to play.
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"TNG_Theme"
ofType:@"mp3"];
// Convert the file path to a URL.
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
//Initialize the AVAudioPlayer.
self.audioPlayer = [[AVAudioPlayer alloc]
initWithContentsOfURL:fileURL error:nil];
// Preloads the buffer and prepares the audio for playing.
[self.audioPlayer prepareToPlay];
[filePath release];
[fileURL release];
}
-(IBAction)play {
// Make sure the audio is at the start of the stream.
self.audioPlayer.currentTime = 0;
[self.audioPlayer play];
}
-(IBAction)stop {
[self.audioPlayer stop];
}
+0
嗨Fulvio, 我只是在用户按下不正确的键时发出标准系统嘟嘟声。 – WaterBoy 2010-08-18 04:24:22
1
AudioServicesPlaySystemSound是一件你可以做的简单的声音。
相关问题
- 1. Xamarin使用哔声()
- 2. IE输入哔哔声
- 3. 下面的代码如何使PC发出哔哔声?
- 4. 如何使Windows服务哔声?
- 5. Java Swing - 如何在任何JOptionPane之前发出哔哔声?
- 6. ALT +快捷键会发出“哔哔”声
- 7. 在Linux中发出哔哔声C
- 8. 哔声流激活
- 9. 如何在Click Mouse中禁用哔声?
- 10. 如何将SpeechRecognizer的哔声静音?
- 11. 如何关闭Eclipse中的哔声?
- 12. 如何用PyFace发出哔声?
- 13. 无限制系统扬声器哔哔声
- 14. 使用MediaPlayer播放谷歌电视上的通知哔哔声
- 15. 如何使用批处理文件从内置PC扬声器启动系统“哔哔声”?
- 16. 使用sl4a发出手机哔声
- 17. Phonegap哔声/声音iOS错误
- 18. 如何在输入按下时防止文本框发出哔哔声?
- 19. 如何使C#计算机发出哔声?
- 20. 在Maven构建过程中发出计算机哔哔声
- 21. c#避免在KeyDown按下发出哔哔声?
- 22. 避免哔哔声按下输入数字上下对话框
- 23. 如何防止MaxLength发出哔哔声或者完全防止应用程序发出蜂鸣声?
- 24. 在背景中播放哔声
- 25. Python程序运行时发出哔声?
- 26. Android播放哔声,每n毫秒
- 27. FF中的音频控制发出哔哔声,OGG和.htaccess已被修改
- 28. Matlab:基于指定尺寸的字符串的哔哔声数量
- 29. 在iPhone上拨打号码以编程方式更改“哔”声是否可行?
- 30. 在android应用程序中执行哔声声音
iOS中没有“标准嘟嘟”的声音。 – yinkou 2011-11-23 19:08:31