AVPlayer layer inside a view does not resize when UIView frame changes

前端 未结 13 906
小蘑菇
小蘑菇 2020-12-23 17:08

I have a UIView which contains an AVPlayer to show a video. When changing orientation, I need to change the size and location of the video.

<
13条回答
  •  旧巷少年郎
    2020-12-23 17:42

    Any one searching for Xamarin Version as i was searching

    don't add the AVPlayerLayer as sublayer but set the layer to Avplayer Layer

    [Export("layerClass")]
    public static Class LayerClass()
    {
        return new Class(typeof(AVPlayerLayer));
    }
    

    The following line set the layer

    (this.Layer as AVPlayerLayer).Player = _player;   // Acplayer
    

提交回复
热议问题