Question

I have a MPMoviePlayerController that is being used to play videos. I'm using subviews to create watermark labels to place over the video. I need the watermarks to be on top of the actual video though not the black space to the sides or top of the video.

I know that I can use the naturalSize to get the original video dimensions. However, when the player view is larger than the natural size, the video stretches to fit the view. Is there a way to get the size of the stretched video in the player view? If I know the real size of the video, I should be able to calculate the coordinates for placing the watermarks properly on top of it.

Any ideas?

Était-ce utile?

La solution

You can get the size of the movie with the property naturalSize.

moviePlayer.naturalSize.height  //to get the height of the frame player

UPDATE!!

Hope it helps

 -(CGRect)getResizedVideoFrame:(CGRect )naturalSize andPlayerViewSize:(CGRect)playerSize {
    float resVi = naturalSize.size.width / naturalSize.size.height;
    float resPl = playerSize.size.width / playerSize.size.height;
    return (resPl > resVi ? CGRectMake(0, 0, naturalSize.size.width * playerSize.size.height/naturalSize.size.height, playerSize.size.height) : CGRectMake(0, 0,playerSize.size.width, naturalSize.size.height * playerSize.size.width/naturalSize.size.width));
 }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top