No sound on iPad with MPMoviePlayerViewController and iOS5, works in simulator

Since I upgraded to iOS 5, I can’t get MPMoviePlayerViewController to play audio on the iPad. The video is perfect but no sound is heard. It doesn't matter which format I use. This does not work. It works in a simulator, but not on an iPad.

- (IBAction)playVideo { NSString *filepath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4v"]; NSURL *fileURL = [NSURL fileURLWithPath:filepath]; moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedPlaying:) name:MPMoviePlayerPlaybackDidFinishNotification object:[moviePlayer moviePlayer]]; [self presentMoviePlayerViewControllerAnimated:moviePlayer]; } 

Does anyone else have this problem? Or have you found a fix?

+4
source share
5 answers

It sounds silly, but we ran into a problem on my team where the volume sound for the common iPad sounds was muffled, and that meant there was no sound for the video played in our application, although the music played through the music player or video on the sites worked fine.

To check this volume control, you can call the task manager (press the home button twice), and then swipe the screen to the far left, and there are some music controls; make sure the mute button on this screen is not turned on.

+11
source

try the following:

 ... moviePlayer.useApplicationAudioSession = NO; [self presentMoviePlayerViewControllerAnimated:moviePlayer]; 
+4
source

set audio recording before distribution MPMoviePlayerController will play sound along with video

 AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryPlayback error:nil]; moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL]; 
+4
source

Make sure the audio format in the video file is what the iPad can play. I believe that the simulator has access to the codecs of the host machine, which may explain why the iPad can play video, but not audio. As noted on this page in the MPMoviePlayerController documentation :

If you use this class to play audio files, it displays a white screen with the QuickTime logo during audio playback. For audio files, this class supports AAC-LC audio at frequencies up to 48 kHz and MP3 (MPEG-1 Audio Layer 3) up to 48 kHz, stereo audio.

+1
source

I just made a slide button on the side of the lock screen. Then the sound sounded bad.

+1
source

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


All Articles