【问题标题】:MPAVController >> Not enough buffered to keep upMPAVController >> 没有足够的缓冲来跟上
【发布时间】:2012-10-26 02:39:00
【问题描述】:

我正在使用此代码播放视频。

player= [[ MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
player.navigationController.navigationBar.hidden = YES;
player.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
player.moviePlayer.controlStyle = MPMovieControlStyleNone;
player.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
player.moviePlayer.fullscreen = NO;
[self presentModalViewController:player animated:NO];

视频播放完美但问题是在完成播放后我在控制台中得到了这个结果。

[MPAVController] Autoplay: Likely to keep up or full buffer: 0
[MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.

然后在我尝试录制声音但无法录制之后。

谁能帮我解决这个问题。

【问题讨论】:

  • 这个问题是出现在ios6还是其他ios版本上????
  • 你能把你正在形成 movieURL 的代码部分贴出来吗
  • 在两个 ios 中我都遇到了问题......即使我在 iPas 中录制,录制任务正在执行但没有声音..
  • 我也有类似的问题stackoverflow.com/questions/14087555/…也许你能帮帮我?!

标签: iphone ios xcode ios6 audio-recording


【解决方案1】:

您需要在播放视频后录制音频,因此您必须使用此通知才能知道电影播放器​​已完成播放视频...为此您需要使用此代码。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:)
        name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];

在该 moviePlaybackComplete: 方法中,您录制了音频。 为此,您最好使用 AVAudioPlayer 类。 现在使用这段代码进行记录..

AVAudioRecorder *recorder = [[AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];

【讨论】:

  • 我正在全屏播放视频,播放完后我正在录制...
【解决方案2】:

同样的任务由我完成...您可以参考我的代码...希望对您有所帮助...

- (IBAction) startRecording:(id)sender
{

    NSLog(@"**************Recording start**************");    

    NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];

    // We can use kAudioFormatAppleIMA4 (4:1 compression) or kAudioFormatLinearPCM for nocompression
    [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];

    // We can use 44100, 32000, 24000, 16000 or 12000 depending on sound quality
    [recordSetting setValue:[NSNumber numberWithFloat:41000.0] forKey:AVSampleRateKey];

    [recordSetting setValue:[NSNumber numberWithInt: kAudioFormatAppleLossless] forKey:AVFormatIDKey];

    // We can use 2(if using additional h/w) or 1 (iPhone only has one microphone)
    [recordSetting setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];

    [recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVEncoderBitRateKey];

    NSError *error;

    if (![[NSFileManager defaultManager] fileExistsAtPath:mediaPath])
    {
        [[NSFileManager defaultManager] createDirectoryAtPath:mediaPath withIntermediateDirectories:NO attributes:nil error:&error];
    }


    mediaPath = [[NSString stringWithFormat:@"%@/sound.caf", DOCUMENTS_FOLDER] retain];
    NSURL *url = [NSURL fileURLWithPath:mediaPath];
    NSLog(@"AUDIOPATH%@",mediaPath);
    err = nil;
    NSData *audioData = [NSData dataWithContentsOfFile:[url path] options: 0 error:&err];

    if(audioData) {

        NSFileManager *fm = [NSFileManager defaultManager];
        [fm removeItemAtPath:[url path] error:&err];

    }

    err = nil;
    audioRecorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:&err];

    if(!audioRecorder){

        NSLog(@"audioRecorder : %@ %d %@", [err domain], [err code], [[err userInfo] description]);
        UIAlertView *alert =
        [[UIAlertView alloc] initWithTitle: @"Warning"
                                   message: [err localizedDescription]
                                  delegate: nil cancelButtonTitle:@"OK"
                         otherButtonTitles:nil];
        [alert show];
        return;
    }

    //prepare to record
    [audioRecorder setDelegate:self];
    [audioRecorder prepareToRecord];

    audioRecorder.meteringEnabled = YES;

    BOOL audioHWAvailable = audioSession.inputIsAvailable;

    if (! audioHWAvailable) {

        UIAlertView *cantRecordAlert = [[UIAlertView alloc] initWithTitle: @"Warning"
                                                                  message: @"Audio input hardware not available"
                                                                 delegate: nil cancelButtonTitle:@"OK"
                                                        otherButtonTitles:nil];
        [cantRecordAlert show];
        [cantRecordAlert release];
        return;
    }

    // start recording
    [audioRecorder record];
}

【讨论】:

  • 其实我已经解决了我的问题,但这是一个相当漫长的过程,所以我会检查你的代码并尽快更新你...谢谢你的帮助
【解决方案3】:

我还发现这些消息可能是由于向媒体播放器发送了不正确的 URL 而导致的。有时候真的就是这么简单。

【讨论】:

    【解决方案4】:

    检查 MPMoviePlayerController 上的 useApplicationAudioSession 属性。在 iOS 3.1.x 中,电影播放器​​总是获得自己的系统提供的音频会话。在较新版本的 iOS 中,它现在可以共享应用程序会话,这也是默认值。在开始播放电影之前尝试将该属性切换为 NO。

    【讨论】:

    • 文档说从 iOS 6 开始不推荐使用此属性,并且不鼓励使用它。
    【解决方案5】:

    我不确定这是否会有所帮助,但您应该将MPMoviePlayerViewControllerpresentMoviePlayerViewControllerAnimated: 一起展示,而不是presentModalViewController:animated:,如下所示:

    [self presentMoviePlayerViewControllerAnimated:player];
    

    如果您手动关闭MPMoviePlayerViewController,您应该使用dismissMoviePlayerViewControllerAnimated

    Here is a thread可能帮助解决 MPAVController 日志的问题。似乎您正在对 MPMoviePlayerViewController moviePlayer 进行大量自定义 - 老实说,您可能会考虑只使用 MPMoviePlayerController 而不是 MPMoviePlayerViewController

    如果没有看到您用于执行语音录制的代码,就无法判断您的语音录制问题是与 MPMoviePlayerViewController 相关,还是您在其他地方有错误。我建议发布更多您的代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-09
      • 1970-01-01
      • 2011-02-09
      • 2015-10-28
      • 2021-09-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多