Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No audio on iPad with MPMoviePlayerViewController and iOS5, works in the simulator

Ever since I updated to iOS 5, I can't get MPMoviePlayerViewController to play audio on the iPad. Video is perfect, but no audio is heard. It doesn't matter what format I use. It does not work. It works in the simulator, but not on the iPad.

- (IBAction)playVideo {

    NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4v"];
    NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];
    moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];

    [[NSNotificationCenter defaultCenter]
     addObserver:self selector:@selector(movieFinishedPlaying:)
     name:MPMoviePlayerPlaybackDidFinishNotification 
     object:[moviePlayer moviePlayer]];

    [self presentMoviePlayerViewControllerAnimated:moviePlayer];

}

Anyone else have this problem? Or found a fix?

like image 890
RyeMAC3 Avatar asked Nov 29 '22 15:11

RyeMAC3


2 Answers

It sounds silly, but we came across an issue on my team where the volume control for general iPad sounds was muted and this meant that there was no sound for video played in our app, even though music played through the music player or video on websites worked fine.

To check this volume control you can bring up the task manager (double-tap the home button) and then swipe across to the far left and there are some music controls; check that the mute button on this screen is not on.

like image 144
Zoodor Avatar answered Dec 06 '22 20:12

Zoodor


try this:

...
moviePlayer.useApplicationAudioSession = NO;
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
like image 24
Fish Avatar answered Dec 06 '22 20:12

Fish