What is the most optimal (in terms of resources and performance) way of recording and playing video file in wpf (windows) application? While I am still guessing how to record, I tried playing video using MediaElement, the problem is that it shows black screen
initially (first time only) for few seconds. How to avoid that ?
WPF doesn't support video recording, as to the video playback, does the video file reside on the remote location or it just sits in the local file system, how large is it?
The video file resides locally and is around 5 MB in size. The black screen appears only for the first time, caching - can that be a culprit ? I am allocating the source dynamically and the xaml for the control looks like -
Huh, Have you ever tried your WPF app on other PCs which have different GPU specs, AFAIK, MediaElement will behave quite differently on some GPUs.
Ok, I tested the application on different machines, updated drivers and all other tricks that I found on different blogs.... nothing seems to be working for me . after spending half of my day I have found that the problem of black screen arises when
I try to use the mediaelement for playing different video files i.e. when I try to assign source dynamically. The application works fine if I play single video.I tried different UnloadedBehaviors but to no avail. Using MediaElement.Stop() to stop the video.
With little more research on the matter I found that the problem is with setting the source of a mediaelement when it already has one. What is the exact way to reassign the source of mediaelement I mean should I set it to "null" before reassigning, should
I use MediaElement.Close() ?
I haven't test it, but I think the behaviour you see is really reasonable, since in order to play back videos more efficiently, WPF will actually load the video file into video memory, I reckon this process takes time.
Can MediaPlayer be helpful in such a scenario ?
I am trying to load video dynamically also. I noticed that while setting the source, the video went black for a period of 10 seconds prior to playing. Some files are only 2 megs while others are 20. I am replacing a Flash application with a WPF application
and can't get the user experience to match since the video takes too long to load. Is there a streaming property to get this video to play faster?
What kind of application, you are working on - Windows or Web ? Buffering can help you put, if its web application.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.