0

I am playing video using this code.

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];

Video playing works perfectly But the problem is that after finishing play i am getting this result in console.

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

and then after i am trying to record the voice but unable to record.

can anybody help me to solve this issue.

Rajneesh071
  • 30,846
  • 15
  • 61
  • 74

5 Answers5

1

same kind of task is done by me... you can take refernce of my code... i hope it helps...

- (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];
}
Vineet Singh
  • 4,009
  • 1
  • 28
  • 39
  • actually i already solved my problem, but that was quite lengthy process, so i will check your code and update you ASAP...Thanks for your help – Rajneesh071 Jan 04 '13 at 07:11
0

I am not sure if this will help but you should be presenting your MPMoviePlayerViewController with presentMoviePlayerViewControllerAnimated:, not presentModalViewController:animated:, like so:

[self presentMoviePlayerViewControllerAnimated:player];

If you are manually dismissing the MPMoviePlayerViewController you should use dismissMoviePlayerViewControllerAnimated.

Here is a thread that might help solve the issue with the MPAVController logs. It seems like you are doing a lot of customization of the MPMoviePlayerViewController moviePlayer -- you might honestly consider just using an MPMoviePlayerController instead of an MPMoviePlayerViewController.

Without seeing the code you are using to perform voice recording it is impossible to tell whether your voice recording problems are stemming from something to do with MPMoviePlayerViewController or if you have an error elsewhere. I would suggest posting more of your code.

Community
  • 1
  • 1
Michael Frederick
  • 16,664
  • 3
  • 43
  • 58
0

You need to record audio after playing video,so you have to use this notification to know that movie player has completed playing video...For this u need to use this code.

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

In that moviePlaybackComplete: method you have record audio. For this purpose you better to use AVAudioPlayer class. Now use this piece of code for recording..

AVAudioRecorder *recorder = [[AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];
Rajneesh071
  • 30,846
  • 15
  • 61
  • 74
Murali
  • 1,869
  • 1
  • 14
  • 22
0

I also found that these messages can be caused by sending an incorrect URL to the media player. Sometimes it really is that simple.

Steve Rukuts
  • 9,167
  • 3
  • 50
  • 72
-1

Check the useApplicationAudioSession property on MPMoviePlayerController. In iOS 3.1.x, the movie player was always getting its own system provided audio session. In newer version of iOS , it can now share the application session, and that's the default value as well. Try switching that property to NO before starting to play your movie.

Siba Prasad Hota
  • 4,779
  • 1
  • 20
  • 40