Search code examples
c#.netwpfmedia-player

Zoom Video in WPF MediaElement


I like to zoom a video which I play with MediaElement to i.e. 150% but keep the MediaElement Size fixed. This should only show the center of the video on the screen i.e. like a wide screen movie on a 4:3 screen without black bars on the top and bottom.
How can I do this? I checked the MediaElement class and I didn’t find anything like zoom. https://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement(v=vs.110).aspx


Solution

  • Add the media element to a canvas

                    mediaelement.Width = canvas.Width;
                    mediaelement.Height = canvas.Height;
                    mediaelement.Stretch = Stretch.Fill;
    

    For zooming the canvas check the link Canvas zooming