Deepu
Deepu

Reputation: 2616

How to play Video-Audio on iOS 6?

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 ...

Upvotes: 0

Views: 2339

Answers (2)

hfossli
hfossli

Reputation: 22972

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);
}

Upvotes: 0

rckoenes
rckoenes

Reputation: 69489

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);
}

Upvotes: 3

Related Questions