iosvideoavfoundationmovie

AVPlayerLayer animates frame changes


Whenever I change the frame of my AVPlayerLayer, the video is not resized immediately, but animated to the new size.

For example: I change the frame from (0, 0, 100, 100) to (0, 0, 400, 400), the view's frame is changed immediately, but the video's size is animated to the new size.

Has anyone encountered this issue? And if yes does someone know a way to disable the default animation?

Thanks!


Solution

  • You can try disabling implicit actions and using zero length animations:

    CALayer *videolayer = <# AVPlayerLayer #>
    [CATransaction begin];
    [CATransaction setAnimationDuration:0];
    [CATransaction setDisableActions:YES];
    CGRect rect = videolayer.bounds;
    rect.size.width /= 3;
    rect.size.height /= 3;
    videolayer.bounds = rect; 
    [CATransaction commit];