I need a very simple video player in my C# app. It only has to loop a video from file and nothing more. Since I'm developing a WPF application, I've tried to use System.Windows.Controls.MediaElement
. It has all the functions I need, but works quite poor: I've played some full HD videos on it, and it's always lagging and spiking.
To make sure, it's not my app problem, I've created 2 test applications. The first in a WinForms
borderless 1920x1080 window with only AxWMPLib.AxWindowsMediaPlayer
control. And the second in a borderless WPF
window of the same size with System.Windows.Controls.MediaElement
.
Then I run 2 videos on both of players. Here are their specs:
1: 1920x1080, 12000kb/s, 25 FPS, wmv
2: 1920x1080, 5730kb/s, 25 FPS, mp4
On AxWindowsMediaPlayer
everything looks fine. But MediaElement
seems to drop some frames and ignore vertical sync (it's possible to see parts of one frame on another during fast scene changes). So, it's completely unsuitable and shouldn't be like that, but I've found nothing about the problem in Microsoft official docs (they only suggest to use MediaElement
instead of AxWindowsMediaPlayer
in WPF
apps). Is it possible to make it work more smoothly or using an additional WinForms
Form
with AxWindowsMediaPlayer
is the only solution?