为什么我不能在 xamarin 形式 ios libvlcsharp 中更改我的视频大小

问题描述

我想在 xamarin 形式的 ios 中使我的 VideoView 适合屏幕大小,

enter image description here

我使用它,但我无法获得合适的尺码

 MediaPlayer = new MediaPlayer(LibVLC)
 {
       Media = media,EnableHardwareDecoding = true,AspectRatio = $"{App.ScreenWidth}:{App.ScreenHeight}"
 };

所以我使用了全屏属性

 MediaPlayer = new MediaPlayer(LibVLC)
 {
       Media = media,Fullscreen = true
 };

它不能给我想要的结果 我制作了自定义渲染器并覆盖了 OnSizeAllocated() 方法, 我猜改变视频视图大小也会改变视频大小。

   protected override void OnSizeAllocated(double width,double height)
   {
         base.OnSizeAllocated(width,height);

         if (width > height)
         {
              if (height * 16 / 9 > width)
              {
                   VideoView.WidthRequest = width;
                   VideoView.HeightRequest = width * 9 / 16;
              }
              else
              {
                   VideoView.HeightRequest = height;
                   VideoView.WidthRequest = height * 16 / 9;
              }
         }
         else
         {
              if (width * 9 / 16 > height)
              {
                  VideoView.HeightRequest = height;
                  VideoView.WidthRequest = height * 16 / 9;
              }
              else
              {
                  VideoView.WidthRequest = width;
                  VideoView.HeightRequest = width * 9 / 16;
              }
         }
   }

同样我没有得到想要的结果 另外我尝试了各种方法,比如--fullscreen选项等

如有错误,请多多指教

https://github.com/Sunday5214/vlcExample

上面的链接是我的例子

在我检查答案后,我尝试了解决方案

        MediaPlayer = new MediaPlayer(LibVLC)
        {
            Media = media,Scale = 0,AspectRatio = $"{App.ScreenHeight}:{App.ScreenWidth}"
        };

仍然无法全屏显示,

我知道了一些有趣的事情,如果我将手机旋转到横向然后旋转到纵向,我可以全屏

enter image description here

在旋转之前,

enter image description here

旋转后

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)