I am a beginner in iOS development. I am developing an application where I require the size of a video which is getting played in the MPMoviePlayerController.
I am using the property naturalSize of MPMoviePlayerController to get the dimensions of the video that is played.
@property(nonatomic, readonly) CGSize naturalSize;
But the problem is that I can get the natural size only when the Video gets played in the MPMoviePlayerController.
Is there a way in which I can get the dimensions of the video before it gets played in the MPMoviePlayerController.
-- EDIT --
Is there any other workaround I can approach to solve this problem? Please help.
It takes time for the MPMoviePlayerController to load the video metadata, so you should add a listener and wait for the naturalSize to be loaded. Something like this:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieNaturalSizeAvailable:)
name:MPMovieNaturalSizeAvailableNotification
object:myMoviePlayer];
And in movieNaturalSizeAvailable:
, myVideoPlayer.naturalSize
gives you the desired value and after that, you can play the video.