1
votes

I am playing video in MPMoviePlayer in my app,I am fetching the video from server. If the video length is about 25sec or more,the audio gets break.Means while playing the video when it reaches half then there is no audio can be heared.But if I seek the progess bar,audio again comes.

Can any one help me in this ?

moviePlayerController = [[MPMoviePlayerController alloc] init];
[moviePlayerController prepareToPlay];
moviePlayerController.shouldAutoplay = YES;
[moviePlayerController setScalingMode:MPMovieScalingModeAspectFit];
[[self.moviePlayerController view] setFrame:CGRectMake(0, 72, 320,180)];
[[self view] addSubview: [self.moviePlayerController view]];
self.moviePlayerController.useApplicationAudioSession = YES;

 NSString *strng = @"http://qdemo_videos.s3.amazonaws.com/1360582540.mp4";
 NSURL * adurl = [NSURL URLWithString:strng];
 moviePlayerController.contentURL = url;
 moviePlayerController.controlStyle = YES;
 self.moviePlayerController.useApplicationAudioSession = YES;
  [moviePlayerController play];
1
Test that exact video file / stream within your regular mobile safari browser to find out if the issue is connected to your code. Hint: it wont be your code but an encoding issue. - Till
exactly..thank u till How to make that fine ?? - user2000452
@NithinMK did u got the solution ? - vishwa.deepak
yes..It was converting issue at server side - user2000452

1 Answers

-1
votes

If u are building on Xcode 4.6 or above and using iOS 6.0 or above then,

self.moviePlayerController.useApplicationAudioSession = YES;

will not be called as its deprecated.

For further use this link: Here's the doc http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVAudioSession_ClassReference/Reference/Reference.html

Here's the explanation http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Configuration/Configuration.html

And if it's not enough here is the code :) http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html#//apple_ref/doc/uid/TP40007875-CH6-SW2

In my case setting the category to AVAudioSessionCategoryAmbient did the trick!