1

When a new MediaElement is made and inserted into a Grid, it is auto-sized to fit the entire Grid size. How can you adjust the proportions of the MediaElement to mimic the video's original size ?

Grid gDim = new Grid();

MediaElement plr = new MediaElement();
plr.Source = new Uri(my_string); // web link to video file
plr.Play();
plr.Width = plr.NaturalVideoWidth ;
plr.Height = plr.NaturalVideoHeight ;
plr.AreTransportControlsEnabled = true;

gDim.Children.Add(plr);

Setting the NaturalVideoWidth/Height makes the MediaElement go invisible.

Arctic Vowel
  • 1,492
  • 1
  • 22
  • 34

1 Answers1

1

Did you try my advice for this case(using Stretch property)?

<MediaElement Stretch="None"/>
RenDishen
  • 928
  • 1
  • 10
  • 30