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.

4
  • Is the problem coming on ios6 or on other ios versions too ????
    – spider1983
    Nov 15, 2012 at 7:07
  • can you post the part of your code where you are forming your movieURL
    – spider1983
    Nov 15, 2012 at 7:30
  • in both ios i am getting problem...even when i was doing recording in iPas then recording task is performing but without voice.. Nov 16, 2012 at 8:23
  • I have a similar kind of problem stackoverflow.com/questions/14087555/… Maybe you could help me ?!
    – Alexiosdev
    Jan 2, 2013 at 21:49

5 Answers 5

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];
}
1
  • 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 Jan 4, 2013 at 7: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.

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.

0
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];
1
  • i am playing video on full screen and after playing completely i am doing recording... Nov 16, 2012 at 8:27
-1
+100

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.

1
  • The docs say that this property is deprecated as of iOS 6, and its use is discouraged. Nov 19, 2012 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.