I have a C# Windows Form application that plays local videos. I would like to overlay a small form with controls over the video while it is playing. The video is owned by a panel and I have tried to create another panel that contains controls like a button and textbox and tried to brind the whole panel forward and send the video back, but the video stays on top.
Any ideas?
You typically cannot place controls on top of video without having flickers and unwanted artifacts. This comes from the fact that video playback allocates specific video hardware resources to stream video and streaming takes place separately from the rest of UI. Applications such as players "mix" overlay images (including those which mimic controls) into video or otherwise display them through specialized APIs, those are not regular controls.
The easiest solution for you is to place controls side by side to the video, without putting one on top of the other.
Related
I have a WinForms WebBrowser control in a WPF WindowsFormsHost, but I've verified the problem in straight WinForms as well as several different computers.
What happens is whenever a webpage is playing music and I start scrolling the page the audio freezes and repeats the same short sample over and over again. One of the most pronounced sites that exhibits this is Google Play Music.
Is there anything I can do to mitigate this problem?
Try enabling GPU rendering for your WebBrowser control via FEATURE_GPU_RENDERING feature. Here is how to do it, and there's a bunch of other features to play with.
I have built a Windows Phone application with a video player to show a logo animation at startup.
If I launch an external application (like Spotify) with background audio (for example a song) and then switch to my application, the song is stopped (probably because of my logo animation) even though my logo animation doesn't even have audio.
I used a MediaElement for the logo animation :
<MediaElement AutoPlay="False" Name="media" Source="Assets/video.mp4"/>
In the code behind I use media.play(); to start the logo animation.
Is there a way to avoid stopping the sound of other applications?
From the MSDN:
When a MediaElement control plays audio or video content, any
background sounds or media already playing are halted. The app
launches the playback experience when the user taps the control. Only
one MediaElement control can operate at a time.
What this means for you is that you need to redesign the logo to run via XAML animations or some other means besides MediaElement if you want background audio to function properly. Depending on where your animation is coming from, this might be simple for you or it might be outside your scope. You'll have to determine for yourself if the benefits of background audio (Pandora, Spotify, Podcasts, etc) outweighs the work required.
That being said, I've used a large number (probably 20% in my testing) of apps that cancel background audio every time you enter them, and it's extremely frustrating. I think most users would prefer you fixed your application so that background audio is not interrupted.
I want to add a transparent label or textbox over video control when playing it flickers but in wpf i used label above mediaelement and it was perfect.
How can get the same behavior in c# winforms or native c++ or whatever you know?? i'm using vlc media player control
how the wpf do it? the way?
You will have to either:
A. Disable the hardware acceleration for video playback.
B. Use a library for directX and intercept the frames redrawing your content on top of the frame.
This library may help but it's been a couple of years since I played with video technology.
http://directshownet.sourceforge.net/
I have a requirement to play a video file in C# (with audio) then to be able to fade out the video to a black screen then fade in another video.
I've looked at DirectShow & DirectShowNet however I'm none the wiser. I've got a simple app to play a video with a time counter etc, however I'm flummoxed with filters & graphs.
What direction do I need to go in?
Create a WPF Apllication and use the MediaElement Control to play the videos. Use the events of the MediaElement (for example MediaEnded) to detect when to start fadeout / switch streaming source / fadein. The easiest way for the fadeout is to change opacity of the Mediaelement.
The MediaElement should be able to play all videos which have a directshow filter installed on your system.
Are you using WPF?
With WPF you could do this in a variety of ways. eg you could simply animate the video control's (MediaElement) opacity.
NOTE: you can use WPF controls inside of a Winforms app. See this video for how to do this.
One solution, although I would consider it a hack, would be to draw a black overlay ontop of the viewable area of the video. You can adjust the transparency of the overlay based on the frame/time of the video. Essentially, you would fire off a timed event that would slowly remove or add transparency to the overlay based on where in the video you want to starting fading.
I have a WPF Kiosk application and it has a background timer that will redirect the user back to the home page when there is no user activity. When the Kiosk is sitting on the home page for an extended period of time, I want it to have some sort of screensaver. The screensaver would basically have to pull images/videos/flash files from a folder and automatically cycle through them repeatedly until a user is active again.
The dispatch timer should be easy enough to handle the idling, but my question is what is the best way to handle the cycling of the images/videos? Is there a control that will do this for me? I'm sure I can load all of the images and videos, but I'm not sure how to display them to the user in WPF.
I'd need to display the image for a few seconds each, but videos or flash files need to play to completion before being swapped out.
I believe that you'll need to handle each of these cases separately. I assume that you know how to use an Image element, so I won't provide a link to that.
For media files, you can use the built-in Media Element class, which supports WMV and MPG files, and has properties and events for all that you would expect it to (play/pause/stop, Media ended, etc.).
For Flash, it gets a little trickier, as there is no built-in support for this that I'm aware of. Here is an MSDN thread that discusses how to do this.