protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); //Calculate width and height for easier reading width = r - l; height = b - t; //If in Landscape, we want to make sure we are in full screen if (Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape) { //Landscape Orientation view.Layout(0, 0, width, height); videoView.Layout(0, 0, width, height); //You must also set the size of the videoView holder, or else full screen won't work //If the layout of the videoView increases, that doesn't mean the holder that holds the video automaticall increases videoView.Holder.SetFixedSize(width, height); } else { //Portrait Orientation, just layout everything nomally view.Layout(0, 0, width, height); videoView.Layout(0, 0, width, height); //Still need to do this to ensure when you rotate from Landscape back to Portrait, the values are reset videoView.Holder.SetFixedSize(width, height); //playButton.Layout (0, height - 150, width, height); } }
private void UpdateVideoSize() { if (Element.Aspect == VideoAspect.Fill) { _videoView.Layout(0, 0, Width, Height); return; } // assume video size = view size if the player has not been loaded yet var vWidth = _videoWidth > 0 ? _videoWidth : Width; var vHeight = _videoHeight > 0 ? _videoHeight : Height; if (_videoWidth < 0 && _videoHeight < 0) { return; } var scaleWidth = Width / (double)vWidth; var scaleHeight = Height / (double)vHeight; double scale = 1; switch (Element.Aspect) { case VideoAspect.AspectFit: scale = Math.Min(scaleWidth, scaleHeight); break; case VideoAspect.AspectFill: scale = Math.Max(scaleWidth, scaleHeight); break; } var scaledWidth = (int)Math.Round(vWidth * scale); var scaledHeight = (int)Math.Round(vHeight * scale); // center the video var l = (Width - scaledWidth) / 2; var t = (Height - scaledHeight) / 2; var r = l + scaledWidth; var b = t + scaledHeight; _videoView.Layout(l, t, r, b); }