I m working on this project, the client gave me the task to design the UI and embed videos. The backend code of that application is complete according to the client and the backend code is really poorly written with zero optimization.
The application is working perfectly, the application starts the main form loads axWindowsMediaPlayer form with it self and axWindowsMediaPlayer loads videos through resources. The issue is that in the beginning of each video the media player blinks, like if the playlist have 3 videos it'll blink 3 times and if I run the axWindowsMediaPlayer form separately it doesn't blink at all.
I've no idea what to do here.
Standart windows media player control is way too dated. It's basically good for nothing at this point. I'd just open nuget package list and look for any video player control. In case there is none, you can always just add a chromium-based webview element and play your video in there.
Related
I have problem with handling multiple video windows in directshow.
I have app in c# that captures video stream of my webcam and sends it through infinite pin tree to 2 separate renderers. When I run the app each of the renderers gets its own VideoWindow. Now when I set VideoWindow Style I can see changes only on one of them (looks like it is 2nd renderer window). Secound window is not effected at all. What should I do to access both of them? There is only one graph to build entire thing. Is there a way to reference videowindow by the renderer not by the graph? I was looking around web but there is nothing thats was able to point me in to good direction.
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?
It was written over five years ago (look up James Dailey messages in the thread), there were possibly some improvements but overall I suppose the statements are still in good standing. I will pick up some relevant quotes:
As you know the WPF environment is constructed from the ground up to offer developers a very rich “graphics first” environment. The MediaElement in particular was designed to allow you to mix video with various other UI components seamlessly. This solution will give you the flicker free, “draw over video” solution that you are looking for. The best part is you can do all of this in C#. The bad part of this solution is that the MediaElement is not designed for displaying time sensitive media content. In other words, the MediaElement is notorious for dropping and delaying the display of video frames. There are ways to minimize this such as using SD rather than HD content, use a video accelerated codec, etc.
also:
Unfortunately you can’t really tell the WPF MediaElement to never drop frames. The term we use for this class of issues is “disparate clocks”. In this case WPF is updating the screen at a certain rate (clock 1). The MediaElement (based on WMP) is cranking out video frames at a slightly different rate (clock 2). Given the underlying technologies there is currently no way to synchronize the two clocks and force them to “tick” at the same rate. Since the display will only be updated according to the WPF clock, multiple frames of video may be sent from the MediaElement to WPF between clock ticks. Because of this the MediaElement may appear to drop frames. This is a very common problem in multimedia development and there is no simple solution.
Windows Media Player uses Media Foundation and DirectShow APIs which power media playback with high quality video experience.
Windows Phone 8 app.
We're using AudioStreamingAgent/Mp3MediaStreamSource to play MP3 files which could be cached locally or loaded from web.
When file is downloaded we are still using AudioStreamingAgent /Mp3MediaStreamSource to ensure we will be able to precache next file while playing current.
Yes, we could use just WP8 built-in player for cached files, but we will not be able to precache next file in this case.
Problem:
After several tracks, BackgroundAudioPlayer doesn't start playing anymore.
AudioStreamingAgent.OnBeginStreaming is executed
Сode to create MediaStreamSource is executed
AudioStreamer.SetSource method is executed with new MediaStreamSource instance
PlayStateChanged is fired in background process with PlayState.TrackReady and player.Play() is called in this case.
After all, I see the track is shown in UVC, but it's in state "Paused". Pressing "Play" in UVC calls OnUserAction in background which calls player.Play(). Nothing changes.
Picture of "stuck state"
Sample with problem reproduction, VS 2012 (sample is based on Background Audio Streamer Sample)
Steps to reproduce with sample code:
Install app
Press button "Preload tracks". It copies mp3 files from XAP to IsolatedStorage.
Press "Track 1" button. After track starts playing, press button "Track 2". Then, after track 2 starts playing, press button "Track 3".
Keep doing step 3 until after pressing "Track *" button track doesn't start playing.
Last track selected will be shown as an active track both in UVC and above progress bar on the page (see picture)
Pressing other track buttons in most cases doesn't make any difference.
The problem is reproduced both on device and on emulator, both on WP8 and WP8.1 developer preview.
Update: Running out of memory is not the case. Reproducing the problem using sample code and looking at the backgroundlog.xml file shows that sample uses only 6 Mb out of 20 Mb allowed Last column on this picture is "Memory usage|Max allowed memory usage"
In my experience with this, my suggestion would be to port and start working with WPA8.1 where the limitations with playing background audio go away.
In developing a music player app for WP and trying to cache music while using a mediastreamsource, I finally came to the conclusion that it might not be possible. It seems that you have a set amount of time or some other variable before the OS stomps on any tasks or background type work being done.
I wrote this up for a MS evangelist:
https://drive.google.com/file/d/0By_e5C-QWr9Ka3RmbVBlWVF3R1E/edit?usp=sharing
Here are some other SO's I favored when trying to solve this:
BackgroundAudioPlayer is 'Playing' but not calling GetSampleAsync()
WP7 background audio resources are no longer available
HttpWebRequest from AudioPlayerAgent
AudioPlayerAgent, timer and webservice
WP7 Mp3MediaStreamSource demo not working
Hello I am writing a WPF application which should plays a set of videos which should played fullscreen.
i tried to work with some VLC lib's but they did not worked for me.
then i moved to mediaelement - when i start playing a video i always get a black flicker
loading multiple videos was a huge performance loss - videos stuttered...
any recommendations how to resolve this issue ?
i plan do the following programm:
the kinect detects people which move along --> the programm plays a video
if people stop and watch the screen --> the programm plays a extended version
UPDATE: checked vlc.net and it will also have a BLACK frame at the beginnign -- ARGH !
UPDATE: seems like the first frame is always black!? hmmm (added timer and started the video 1 second after it was loaded - still have the black frame ...)
Solution for my application : i use vvvv.org and send my data trough a UDP connection - i handle the video stuff in this VVVV application - works great ... i am very disapointed by microsofts video support ... i hope this will get better in the future thx anyways :)
I have C# windows application in which one can play videos. I have used three options i.e WPF mediaelement, Windows media player activex component and vlc activex component. In my application. In this I plays video using one of the component at a time. And for that I use two instances of that particular component i.e. first video will play in first instance, then second video will play in second instance, then third will play in first and fourth will in second like this it will go on. the play duration is min 5 secs to some hrs. Now,
When I use WPF media element after some hours the form gets blank and application hangs (I have log4net to log and whenever it gets blank it stops logging) but in task manager instaed of showing not responding it shows running. Also, sometimes it takes lots of memeory.
When I use WMP or VLC activex com object after some hrs appliaction goes in non responding mode and task manager shows it correctly. In this there is no memory problem.
After seeing the above results I strated disposing the objects after its turn gets over. So for each video there is a new instance of the above mentioned components. But still I am getting same problem?
I'm working on a similar project to yours where I'm using VLC activex. I experienced the same problems you are describing. To solve this issue, I've added the VLC pluging in a a GroupBox and disabled the GroupBox by setting the Enabled property to false. Let me know if it works for you.