Sound played through headphones only on specific devices using MPMoviePlayerController

I have a strange problem for all of you.

MPMoviePlayerController perfectly reproduces video, and sound is reproduced only through headphones.

The real drag and drop is that this only happens on some iPad and iPhone, even in the EXACT EXACT MODELS by running the SAME EXACT SYSTEM!

I created a simple failure example:

http://www.porcaro.org/MPMoviePlayerController/TestMovie.zip

I saw how it works fine and doesn't work on iPhone 4S, iPhone 4 and iPad 2.

Here is the most appropriate code. Thanks for any insight, I will also send an Apple error:

(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; moviePath = [NSString stringWithFormat:@"%@/intro.m4v", [[NSBundle mainBundle] bundlePath]]; NSURL *movieURL = [NSURL fileURLWithPath:moviePath]; theMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; controlStyle = MPMovieControlStyleEmbedded; movieView = [self view]; movieRect = [[self view] frame]; controlStyle = MPMovieControlStyleFullscreen; theMoviePlayer.controlStyle = controlStyle; theMoviePlayer.view.userInteractionEnabled = YES; if (1) { NSLog(@"Created theMoviePlayer: %@. Playing: %@", theMoviePlayer, moviePath); } [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkForEndOfMovie:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:theMoviePlayer]; // this line doesn't fix the problem //[theMoviePlayer prepareToPlay]; [[theMoviePlayer view] setFrame:movieRect]; [movieView addSubview: [theMoviePlayer view]]; [theMoviePlayer play]; } 
+4
source share
2 answers

This is an old question, but maybe it will help someone. I ran into the same problem and found out that this happens when the phone is in silent mode.

The solution is to set the player's useApplicationAudioSession property to false.

 [theMoviePlayer setUseApplicationAudioSession:NO]; 
+5
source

This problem happened to me after playing video on iPad 2 using mpMoviePlayer. The video played perfectly, but the sound comes only when the headphones are connected.

Solution to the problem:

 [theMoviePlayer setUseApplicationAudioSession:NO]; 
0
source

Source: https://habr.com/ru/post/1395535/


All Articles