Losing my playback window handle/primary surface in directshow? - wpf

I am using WPF and Directshowlib to render video to a HWndHost object. I'm having two problems with this, probably related.
If I start up my application and then switch to another app running fullscreen, e.g. World of Warcraft, the application returns an error when calling IVMRFilterConfig::SetRenderingMode(VMRMode.Windowless);:
0x887600E1, DDERR_NOEXCLUSIVEMODE, Operation requires the application to have exclusive mode but the application does not have exclusive mode.
In other circumstances, when the video window is fine and video playing back, if I cause a UAC Dialog by, for example, starting another application as Administrator or if I lock the screen I also lose the playback window. My video rendering window goes grey and video playback just stops (I get no media ended events any more). I get no error, just a grey rendering window.
What can I do to ensure I get and keep a video window in both these circumstances? Why am I losing the video window anyway?
Thanks!

Related

WPF one app rendering affects other app renderings

I have come across a strange problem.
Basically my app has a primary and a secondary window, the latter is shown on the second monitor. The secondary window has a marquee text animation going 24/7. For the secondary window, I had created a seperate thread with its own Dispatcher, so that the primary window's UI thread could not affect it.
Now I found out, that whenever I moved a modal window on the primary window with the mouse, the movement was sluggish and the marquee text animation became jerky. So I figure, that despite the separtae UI threads, the rendering thread is still the same for the entire process.
My next step was to move the second window to it's very own executable (a seperate Visual Studio project). But even with both windows living in their own processes, still the marque text animation becomes jerky when I move a modal window around in the primary window?!?
How can one application affect another application's rendering so drasticaly?
How to overcome this issue?
I'm using Win 7 x64, Core i5, nVidia GTX 670, .NET 4.5.1.
Edit:
I tried creating a seperate application with Windows Forms, that had a single Label control moving like a marquee, albeit with a regular timer (interval 15ms).
In my main WPF application I launched the primary window without the secondary window and still, moving a modal window inside the primary window causes the marquee in WinForm app to lag and become jerky :S

Mono GUI Window can not be refreshed after moving from one window to another window

I have ubuntu 12.04 and mono 2.10.8.1 in my Linux PC.
I have one .NET application which continuously capturing image from camera connected in my development board.
It is working fine without any issue if i don't move my GUI windows which is continuously capturing image. But when i moves the tab to another window and get back to mono GUI window at that time GUI can not be refreshed and doesn't display live image from camera.
Also, I have also put one panel in which some data like frames and seconds are also going to displayed fine when application is running properly without moving tab to another window. But when i moved the tab into another window at that time same issue caused here that frames are also not going to refreshed in to that panel.
SO, does any one have idea about what is happening in this condition?
Is there any limitation about mono to refresh GUI window or something else?
Please let me know if any one have update as soon as possible.

How do you detect tablet PC screen rotation in a full screen Silverlight application?

I am working on a Silverlight 4 out of browser (OOB) application on a Windows 7 tablet PC. The majority of the time, the program is in full screen mode. However, if the user rotates the tablet, the application rotates and stays full screen, but is scaled for the previous screen orientation. Taking the application out of full screen and putting it back into full screen rescales everything correctly. Is there any way I can detect when the screen rotates? So far I've tried the app's Resize, LayoutChanged and FullScreenChanged events and have a handler for the main page's SizeChanged event. None of these get fired when the application is rotated in full screen mode.
Per Josh Einstein's suggestion, I tried polling the ActualWidth/Height of the application on a timer. It looks like after the rotation, the ActualWidth/Height values returned from the Silverlight plug-in are the pre-rotated values. Only taking it out of full screen and putting it back in full screen will change the resolution of the plug-in. The HtmlPage.Eval hack didn't work since I am OOB.
The WP7 version of Silverlight has the OnOrientationChanged event, which doesn't seem to be available in the desktop version. Anyone have any ideas?
Great question but as far as I can tell, it doesn't seem to be possible. I tried changing the screen resolution in a virtual machine (orientation change is really just a screen resolution change that results in width being larger than height or vice versa) and could not trigger any layout events.
The issue seems to be that the Silverlight plugin itself is not resized. With an elevated out-of-browser application you could presumably use COM interop with WMI to get the actual screen resolution, but it's kind of hacky. If it's an in-browser application, you could use the HTML DOM. In both cases, you'll probably have to poll for the current screen resolution instead of being notified via an event.
Mister Goodcat has written a blog post about how to get at this information in both scenarios.
I would file it as a Silverlight bug too.

WPF Exclusive mode

Is it possible to run a WPF application in exclusive mode - where it owns the entire screen? I want to do full screen video playback.
If you set the WindowStyle to None and maximize then you will take over the full screen - including task bar. But then you have to implement your own window chrome.

WPF MediaElement video playback tearing

I'm trying to use the MediaElement control in WPF to play back video. It works great in Vista, but when I run it on an XP machine I get tearing in the display. It looks as if it's not using the vertical synch, and just updating the screen mid-draw.
Anyone know how to fix this problem?
This has more to do with the way WPF renders to the screen under XP compared to Vista. Under Vista, apps render to an offscreen buffer which is then composited with other windows that have changed and is presented to the screen at the appropriate intervals by a process called DWM.exe. That can (and presumably does) present WPF's window updates to the video buffer synchronized with the refresh interval.
On XP WPF uses DirextX to render straight to the screen and updates the video buffer whenever it wants to. There might be some way to get it to synchronise with the refresh interval, but I haven't looked into it because I don't use XP any more.

Resources