C# Windows Phone 8.1,正在剪切旋转视频

C# Windows Phone 8.1,正在剪切旋转视频,c#,windows-phone-8.1,video-player,C#,Windows Phone 8.1,Video Player,我必须旋转视频,但我有以下问题: 第一个(左上角)是原始视频,如您所见,我必须旋转90º。在景观中没有问题(右上角)。但当我在纵向旋转(左下角)时,视频被裁剪 我认为问题在于视频中有一部分在手机外,而这一部分被删除了,正如您在最后三张图片(右下角)中所看到的(这就是我所想的,我不确定这是否是问题) 这是我的代码: stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); videoPlayer.RenderTran

我必须旋转视频,但我有以下问题:

第一个(左上角)是原始视频,如您所见,我必须旋转90º。在景观中没有问题(右上角)。但当我在纵向旋转(左下角)时,视频被裁剪

我认为问题在于视频中有一部分在手机外,而这一部分被删除了,正如您在最后三张图片(右下角)中所看到的(这就是我所想的,我不确定这是否是问题)

这是我的代码:

stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

videoPlayer.RenderTransform = new CompositeTransform() { Rotation = rot};

videoPlayer.SetSource(stream, file.FileType);
videoPlayer.Play()

Rect bounds = ApplicationView.GetForCurrentView().VisibleBounds;
switch (rot) {
    case -90:
    case -270:
    case 90:
    case 270:
         videoPlayer.Height = bounds.Width;
         videoPlayer.Width = bounds.Height;
         break;
    default:
    case 0:
    case -180:
    case 180:
        videoPlayer.Height = bounds.Height;
        videoPlayer.Width = bounds.Width;
        break;
}
在xaml中:

<MediaElement Name="videoPlayer"
              AutoPlay="True"
              Stretch="Uniform"
              HorizontalAlignment="Center"
              VerticalAlignment="Center"
              RenderTransformOrigin="0.5,0.5"
              AreTransportControlsEnabled ="False"/>

有人能告诉我如何在没有这种裁剪的情况下旋转视频吗

(拉伸值不影响,我尝试了所有可能的值,但什么都没有,结果相同)


谢谢,

因为我认为裁剪的问题是因为网格(或其他)面板。它可能会在旋转之前裁剪视频/媒体元素,因此在该变换后,您会将其视为正方形

我尝试了您在评论中的代码,并使用Canvas在不剪切的情况下旋转视频:


private void myBtn\u单击(对象发送方,路由目标)
{
myMedia.Source=新Uri(@“ms-appx:///Test.mp4");
Rect bounds=ApplicationView.GetForCurrentView().VisibleBunds;
myMedia.RenderTransform=new CompositeTransform(){Rotation=90,TranslateX=-bounds.Width/2};
double scaleFactor=DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
myMedia.Height=bounds.Width*scaleFactor;
myMedia.Width=bounds.Height*scaleFactor;
}

它适用于wp8.1 Silverlight

<Grid>
  <Canvas Name="gdPlayer"
          HorizontalAlignment="Center"
          VerticalAlignment="Center">
        <MediaElement x:Name="player"
                      Stretch="Uniform"
                      VerticalAlignment="Center"
                      HorizontalAlignment="Center"
                      RenderTransformOrigin="0.5 0.5" />    
    </Canvas>
</Grid> 
旋转0度

player.RenderTransform = new CompositeTransform() { Rotation = 0, TranslateX = -(Application.Current.Host.Content.ActualWidth / 2), TranslateY = -(Application.Current.Host.Content.ActualHeight / 2) };
player.Height = Application.Current.Host.Content.ActualHeight;
player.Width = Application.Current.Host.Content.ActualWidth;

您是否尝试过将路线设置为拉伸而不是居中?是的,同样的问题:-/除了制服之外,您是否尝试过不同的拉伸?您还尝试过设置MediaElement的高度/宽度吗?假设winphone xaml应用程序的工作原理与wpf大致相同,则在使用align stretch时不需要指定宽度和高度,只是作为注释,不确定您是否进行了更改。不,这不太好,因为它使用旋转前的大小,这意味着在portarit中它太小(因为高度先于宽度),而且在景观中高度太大了。谢谢你uuuuu:O-你是最好的!
player.RenderTransform = new CompositeTransform() { Rotation = 0, TranslateX = -(Application.Current.Host.Content.ActualWidth / 2), TranslateY = -(Application.Current.Host.Content.ActualHeight / 2) };
player.Height = Application.Current.Host.Content.ActualHeight;
player.Width = Application.Current.Host.Content.ActualWidth;