录制音频时 xCode 控制台错误

发布于 2024-11-01 21:49:20 字数 4183 浏览 0 评论 0原文

录制声音时出现以下控制台错误。您知道我做错了什么吗?录音工作正常,只是输出非常软。

TIA

2011-04-17 12:51:25.707 FlashCards[18561:1210f] Cannot find executable for CFBundle/CFPlugIn 0x5a64780 </Library/Audio/Plug-Ins/HAL/DVCPROHDAudio.plugin> (not loaded)
2011-04-17 12:51:25.708 FlashCards[18561:1210f] Cannot find function pointer NewPlugIn for factory C5A4CE5B-0BB8-11D8-9D75-0003939615B6 in CFBundle/CFPlugIn 0x5a64780 </Library/Audio/Plug-Ins/HAL/DVCPROHDAudio.plugin> (not loaded)
2011-04-17 12:51:25.712 FlashCards[18561:1210f] Cannot find executable for CFBundle/CFPlugIn 0x5c69e90 </Library/Audio/Plug-Ins/HAL/iSightAudio.plugin> (not loaded)
2011-04-17 12:51:25.713 FlashCards[18561:1210f] Cannot find function pointer iSightAudioNewPlugIn for factory 9BE7661E-8AEF-11D7-8692-000A959F49B0 in CFBundle/CFPlugIn 0x5c69e90 </Library/Audio/Plug-Ins/HAL/iSightAudio.plugin> (not loaded)
2011-04-17 12:51:25.729 FlashCards[18561:c503] start recording

根据要求,我添加代码:

.h 文件片段:

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreAudio/CoreAudioTypes.h>
#import <AudioToolbox/AudioToolbox.h>

@protocol BackViewControllerDelegate;


@interface BackViewController : UIViewController <UITextViewDelegate, AVAudioRecorderDelegate, AVAudioPlayerDelegate, UIAlertViewDelegate>
{
AVAudioRecorder *audioRecorder;
AVAudioPlayer *audioPlayer;
IBOutlet UIButton *playButton;
IBOutlet UIButton *recordButton;
IBOutlet UIActivityIndicatorView *autoCog;
BOOL toggle;
}

@property (nonatomic, retain) IBOutlet UIButton *playButton;
@property (nonatomic, retain) IBOutlet UIButton *recordButton;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *autoCog;

-(IBAction) recordAudio;
-(IBAction) playAudio;

.m 片段

@synthesize playButton; 
@synthesize recordButton;
@synthesize autoCog;

- (void)viewWillAppear:(BOOL)animated {
    NSLog(@"%s", __FUNCTION__);
    [super viewWillAppear:animated];

    //Start the toggle in false mode. PREMISE: WHEN WE GET HERE FIRST, WE ARE NOT RECORDING
    toggle = NO;

    NSError *error = nil;

    //Instantiate an instance of the AVAudioSession object.
    AVAudioSession * audioSession = [AVAudioSession sharedInstance];

    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];

    //Activate the session
    [audioSession setActive:YES error: &error];
}

-(void) playAudio
{
    NSLog(@"%s", __FUNCTION__);

    if (audioPlayer.playing) {
        [audioPlayer stop];
    }

    if (toggle == NO)
    {
        recordButton.enabled = NO;        
        if (audioPlayer)
            [audioPlayer release];
        NSError *error;

        // GET THE APPROPRIATE SOUND FILE NAME
.....

        //CHECK FOR EXISTING SOUNDFILE

        if (![[NSFileManager defaultManager] fileExistsAtPath:soundFilePath])
        {
            UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Oops!" message: @"There is not a sound for this word. Press REC to record one. Press cancel to stop" delegate: self 
                                                      cancelButtonTitle: @"REC" otherButtonTitles:@"CANCEL", nil];

            [someError show];
            [someError release]; 
        }


        NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];

        AudioSessionSetProperty (
                                 kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
                                 sizeof (doChangeDefaultRoute),
                                 &doChangeDefaultRoute
                                 );

        audioPlayer = [[AVAudioPlayer alloc] 
                       initWithContentsOfURL:soundFileURL                                    
                       error:&error];
        audioPlayer.volume = 1.0;
        audioPlayer.delegate = self;

        if (error){
            NSLog(@"Error: %@", 
                  [error localizedDescription]);
        }
        else
        {    
            [audioPlayer play];

        }
    }
    recordButton.enabled = YES;
    //NSLog(@"end of playAudio");
}

I get the following console errors when recording a sound.. Any ideas what I'm doing wrong? The recordings work, except that the outputs are REALLY soft.

TIA

2011-04-17 12:51:25.707 FlashCards[18561:1210f] Cannot find executable for CFBundle/CFPlugIn 0x5a64780 </Library/Audio/Plug-Ins/HAL/DVCPROHDAudio.plugin> (not loaded)
2011-04-17 12:51:25.708 FlashCards[18561:1210f] Cannot find function pointer NewPlugIn for factory C5A4CE5B-0BB8-11D8-9D75-0003939615B6 in CFBundle/CFPlugIn 0x5a64780 </Library/Audio/Plug-Ins/HAL/DVCPROHDAudio.plugin> (not loaded)
2011-04-17 12:51:25.712 FlashCards[18561:1210f] Cannot find executable for CFBundle/CFPlugIn 0x5c69e90 </Library/Audio/Plug-Ins/HAL/iSightAudio.plugin> (not loaded)
2011-04-17 12:51:25.713 FlashCards[18561:1210f] Cannot find function pointer iSightAudioNewPlugIn for factory 9BE7661E-8AEF-11D7-8692-000A959F49B0 in CFBundle/CFPlugIn 0x5c69e90 </Library/Audio/Plug-Ins/HAL/iSightAudio.plugin> (not loaded)
2011-04-17 12:51:25.729 FlashCards[18561:c503] start recording

As requested, I am adding code:

.h file snippet:

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreAudio/CoreAudioTypes.h>
#import <AudioToolbox/AudioToolbox.h>

@protocol BackViewControllerDelegate;


@interface BackViewController : UIViewController <UITextViewDelegate, AVAudioRecorderDelegate, AVAudioPlayerDelegate, UIAlertViewDelegate>
{
AVAudioRecorder *audioRecorder;
AVAudioPlayer *audioPlayer;
IBOutlet UIButton *playButton;
IBOutlet UIButton *recordButton;
IBOutlet UIActivityIndicatorView *autoCog;
BOOL toggle;
}

@property (nonatomic, retain) IBOutlet UIButton *playButton;
@property (nonatomic, retain) IBOutlet UIButton *recordButton;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *autoCog;

-(IBAction) recordAudio;
-(IBAction) playAudio;

.m snippet

@synthesize playButton; 
@synthesize recordButton;
@synthesize autoCog;

- (void)viewWillAppear:(BOOL)animated {
    NSLog(@"%s", __FUNCTION__);
    [super viewWillAppear:animated];

    //Start the toggle in false mode. PREMISE: WHEN WE GET HERE FIRST, WE ARE NOT RECORDING
    toggle = NO;

    NSError *error = nil;

    //Instantiate an instance of the AVAudioSession object.
    AVAudioSession * audioSession = [AVAudioSession sharedInstance];

    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];

    //Activate the session
    [audioSession setActive:YES error: &error];
}

-(void) playAudio
{
    NSLog(@"%s", __FUNCTION__);

    if (audioPlayer.playing) {
        [audioPlayer stop];
    }

    if (toggle == NO)
    {
        recordButton.enabled = NO;        
        if (audioPlayer)
            [audioPlayer release];
        NSError *error;

        // GET THE APPROPRIATE SOUND FILE NAME
.....

        //CHECK FOR EXISTING SOUNDFILE

        if (![[NSFileManager defaultManager] fileExistsAtPath:soundFilePath])
        {
            UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Oops!" message: @"There is not a sound for this word. Press REC to record one. Press cancel to stop" delegate: self 
                                                      cancelButtonTitle: @"REC" otherButtonTitles:@"CANCEL", nil];

            [someError show];
            [someError release]; 
        }


        NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];

        AudioSessionSetProperty (
                                 kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
                                 sizeof (doChangeDefaultRoute),
                                 &doChangeDefaultRoute
                                 );

        audioPlayer = [[AVAudioPlayer alloc] 
                       initWithContentsOfURL:soundFileURL                                    
                       error:&error];
        audioPlayer.volume = 1.0;
        audioPlayer.delegate = self;

        if (error){
            NSLog(@"Error: %@", 
                  [error localizedDescription]);
        }
        else
        {    
            [audioPlayer play];

        }
    }
    recordButton.enabled = YES;
    //NSLog(@"end of playAudio");
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乱了心跳 2024-11-08 21:49:20

我以前见过这些警告,如果您复制了另一个旧项目,会发生什么情况?如果是这样,这就是我所做的,我只是使用最新版本的 Xcode 创建了一个新的空白项目,然后开始将旧文件复制到其中。

这似乎清除了这些错误。

I've seen these warnings before, what happens is you copied another older project? if so this is what i did, I simply created a new blank project with the newest version of Xcode, and then started copying the old files into it.

this seemed to clear out those errors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文