I'm making a VoIP app for iPhone. It's required to to forbid any form of audio recording for security reason. Is it possible to do so? If so, how to do it? Thanks a lot!
Edit: The app is not for jailbroken iPhones. Howev开发者_高级运维er, private frameworks are permissible.
in your .h file -
#import <AVFoundation/AVFoundation.h>
@interface recordViewController : UIViewController
<AVAudioRecorderDelegate, AVAudioPlayerDelegate>
{
AVAudioRecorder *audioRecorder;
UIButton *playButton;
UIButton *recordButton;
UIButton *stopButton;
}
@property (nonatomic, retain) IBOutlet UIButton *playButton;
@property (nonatomic, retain) IBOutlet UIButton *recordButton;
@property (nonatomic, retain) IBOutlet UIButton *stopButton;
In you .m file -
- (void)viewDidLoad {
[super viewDidLoad];
playButton.enabled = NO;
stopButton.enabled = NO;
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSString *soundFilePath = [docsDir
stringByAppendingPathComponent:@"sound.caf"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
[audioRecorder stop];
}
The last line [audioRecorder stop]
is going to make sure the audio recording is stopped. You can do something similar to your app..
精彩评论