Manually controlling video playback aspect ratio

Topics: Windows 8 Xaml
Jan 31, 2013 at 2:05 AM
Edited Jan 31, 2013 at 2:05 AM

I'm running into a scenario where I'd like to set the video aspect ratio manually. Unfortunately, I don't see a way to do that with the Microsoft.PlayerFramework.MediaPlayer class.

E.g. the closest I can see is to do something like this, which doesn't appear to change the actual aspect ratio displayed:
      this.videoPlayer.SetValue(Microsoft.PlayerFramework.MediaPlayer.AspectRatioWidthProperty, 80);
      this.videoPlayer.SetValue(Microsoft.PlayerFramework.MediaPlayer.AspectRatioHeightProperty, 43);
Feb 1, 2013 at 11:56 PM
These properties are readonly and come from the MediaElement as informational only. Are you trying to stretch your video due to non-square pixels? The only way I can think of to do this would be to apply a ScaleTransform to the MediaElement (MediaElement.RenderTransform) -- or by wrapping the MediaElement in a ViewBox control in the xaml which does the same thing under the hood.
Feb 9, 2013 at 7:15 AM
Ultimately the problem came down to the HLS plugin we're using not changing aspect ratio when different MPEG TS segments came down with different aspect ratios.

So problem understood, and not a Microsoft issue. :-)