Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPMoviePlayerViewController crashing app in iOS 10 Xcode 8

Using xcode 8 and running on the ios10 simulator. When trying to use MPMoviePlayerViewController, it will immediately cause my sample application to crash in the simulator. No exception or error is shown in Xcode so not sure how to debug this or what is the problem.

MPMoviePlayerViewController *moviePlayer;
moviePlayer = [[MPMoviePlayerViewController alloc] init];

The above code is enough to crash my app in ios 10 simulator. The app closes immediately and nothing show in xcode. No problems at all on the ios 9 simulator.

What can cause this and is there anything to do to debug the crash?

like image 204
Michael Avatar asked Jun 19 '16 07:06

Michael


1 Answers

Ok I found the solution,

you have to let the user know what your media player is going to access,

  1. Go to the info.plst and add the key NSAppleMusicUsageDescription - string

  2. add some text (just for testing purposes)

  3. run your app. A dialogue box pops up asking for access to the users media. Hit ok and it should run.

I used your code and ran it this way without a crash.

I hope that works.

like image 72
Ro4ch Avatar answered Nov 15 '22 11:11

Ro4ch