greenLizard
greenLizard

Reputation: 2346

MPMoviePlayerController iOS play audio file issue

Hi all I am using MPMoviePlayerController to play both video (mp4) and audio (mp3) files. I am facing an issue when the view is removed form screen, the audio keeps playing in the background, video is ok. On iOS 4.3 everything works great, but when I switch to iOS5 and attempt to play audio and press back (remove the view) the audio is still pressent in the background. Is there something different in how MPMoviePlayerController handles audio files in 4.3 and 5 ? I am using the same code for playing both video/audio.

moviePlayBackDidFinish method, where I stop the player

[player setInitialPlaybackTime:-1];
[player stop];
player = nil;
[[player view] removeFromSuperview];
[player release];

Any help is appreciated :)

Upvotes: 0

Views: 966

Answers (1)

Senthilkumar
Senthilkumar

Reputation: 2481

use this code to pause the audio/video in the MPMoviePlayerController

-(void)viewWillDisappear:(BOOL)animated
{

[mediaPlayer pause];

}

Upvotes: 2

Related Questions