Question

I am playing videos and audio in my iOS app using AVAudioPlayer for Audio files (.mp3 files) and MPMoviePlayerViewController for videos files (.mp4 files).

It works fine on iOS 5 and lower versions.

But in my iPad ( iOS 6) it doesn't work. It plays video with no audio. Of course it doesn't play audio at all.

Please help me to resolve this problem. Thanks in advance ...

Was it helpful?

Solution

Since iOS 6 the mute switch will also mute apps, did you check if the mute swoth is turned off.

To force playback if the device is muted you could do the following:

NSError *error= nil;
if ([[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:&error]) {
    NSLog(@"Error setting audio session: %@", error);
}

OTHER TIPS

NSError *setCategoryErr = nil;
NSError *activationErr  = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&setCategoryErr];
[[AVAudioSession sharedInstance] setActive:YES error:&activationErr];

if(setCategoryErr || activationErr)
{
    NSLog(@"%@ Error: Could not activate silence mode. %@ %@", self, setCategoryErr, activationErr);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top