Skip to content

Video AVPlayerLayer not filling PlayerView #73

@CristianoCastro

Description

@CristianoCastro

I have a video with 360x480 and am playing it on an iPhone4S, but I can see a bit of the underlying imageview image (mainImageView from ASMediaFocusController). Through debug I removed the image and painted the imageview's background red so you can see better what is happening (notice the vertical red near the edges):

iphone4s_screencap

The PlayerView has the correct frame, but it's layer isn't filling it, we need to set videoGravity = AVLayerVideoGravityResizeAspectFillfor it to fill completely the PlayerView. Something like:

- (void)showPlayerWithURL:(NSURL *)url
{
    self.playerView = [[PlayerView alloc] initWithFrame:self.mainImageView.bounds];
    ((AVPlayerLayer *)(self.playerView.layer)).videoGravity = AVLayerVideoGravityResizeAspectFill;
   ...

Doing that the video fills the entire PlayerView as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions