Search code examples
iosorientationmpmovieplayercontrolleralasset

iOS - Is video/image on server portrait or landscape?


If a user uploads a video to a server and I later try to play it with an MPMoviePlayerController from the remote url, how do I know if the video was originally taken in portrait or landscape mode? Same for an image. I need to set the view frame based on the orientation of the original asset.


Solution

  • Your MPMoviePlayerController reports the naturalSize. If the naturalSize.width > naturalSize.height, you've got a landscape video.

    Similarly, a UIImage reports a size. If the size.width > size.height, you've got a landscape image.