简体   繁体   English

如何使用 C# 更改 Windows 媒体播放器的纵横比

[英]How to change the aspect ratio of an Windows media player by using C#

Watching a video on windows media player will produce black bars on the left and right.在 windows 媒体播放器上观看视频会在左右两侧产生黑条。

this.MPlayer.stretchToFit = true;
AxWindowsMediaPlayer mPlayer = this.MPlayer;
mPlayer.URL = "Location of a file";

Below attached file output of the code.下面附上代码的output文件。

How to change the aspect ratio of an Windows media player?如何更改 Windows 媒体播放器的纵横比?

在此处输入图像描述

With C# images you define width and height as double.使用 C# 图像,您可以将宽度和高度定义为两倍。 When you now display your image you can choose between the following stretch options:当您现在显示图像时,您可以在以下拉伸选项之间进行选择:

  • Stretch="Fill" - depending on your width and height the image can be distortedor Stretch="None" - depending on your width and height the image may not fit into the display area Stretch="Uniform" - the image stretches into the display area and completely fills the display area Stretch="Fill" - 取决于您的宽度和高度,图像可能会变形或 Stretch="None" - 取决于您的宽度和高度,图像可能不适合显示区域 Stretch="Uniform" - 图像拉伸到显示器中区域并完全填满显示区域
    • you might have some empty space at upper/lower or left/right border.您可能在上/下或左/右边界有一些空白空间。 The aspect ratio is not changed Stretch = "UniformToFill" - the image stretches and completely fills the display area, the aspect ratio remains intact however to fit into the display area the lower or right part of the imace is cut off.纵横比不变 Stretch = "UniformToFill" - 图像拉伸并完全填充显示区域,纵横比保持不变,但是为了适应显示区域,图像的下部或右侧部分被切断。

For the MediaElement first try Stretch="None", this leaves the display undistorted.对于 MediaElement,首先尝试 Stretch="None",这会使显示不失真。

If your video absolutely does not fit into the display area replace the Stretch argument by SizeToContent="WidthAndHeight".如果您的视频绝对不适合显示区域,请用 SizeToContent="WidthAndHeight" 替换 Stretch 参数。

Regards Martin问候马丁

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM