I need to process frames from web camera on Windows 8.1 phones, tablets and desktop.
I already have implementation for phones and tablets (=store apps) that uses custom media foundation transform to access the frames. Now I’m working on a desktop version.
MSDN says MediaCapture class is supported on both store apps and desktop apps. The third-party MediaCaptureWPF works OK in place of the missing CaptureElement.
However MediaCapture.AddEffectAsync documentation says “effectActivationID: The class identifier of the activatable runtime class that implements the effect.”
And I can’t use a custom WinRT component in a desktop app.
There's also another option to add an effect, MediaCapture.AddVideoEffectAsync, that takes the IVideoEffectDefinition argument instead of the class ID. However that interface is only supported on the phones.
So, my question is.
Can I use MediaCapture class + custom MF transform on Windows 8 desktop platform? How?
Or do I need to developer an MF source reader just to support the desktop platform? Of there's better way?
Thanks in advance.
Looks like MediaCapture isn't compatible with custom MFTs when running on desktop.
I ended up implementing media sink instead, based on the code from this article.
Unfortunately, the relevant parts of the media foundation framework are marked “[desktop apps only]”. It looks I will have to support 2 distinct versions of the frame grabber, one for the desktop, another one for the store + phone.
Related
How can I implement these Windows 10 "media notifications" into a C# WPF desktop application?
You are talking about the SystemMediaTransportControls class. Its usage it described on Microsoft Docs.
However, this API is designed for UWP so getting this to work in a regular desktop application like WPF takes a little more work. There are some answers here on StackOverflow that describe how to do this, but there is also some newer, official documentation from Microsoft on how to use these WinRT APIs.
Unfortunately, the System Media Transport Controls API is not directly supported in Desktop apps [5], so it gets a little more complicated, as described here [6].
In short, for .NET 5:
Install the Windows 10 SDK of a version you like (e.g. through the VS Installer);
Change the target framework to the SDK version you installed, e.g. net5.0-windows10.0.19041.0.
Use the API interops as described on [6] to get an instance.
In the case of SMTP, you'd want to use Windows.Media.SystemMediaTransportControlsInterop. This requires the handle to a window, which you can get with WindowInteropHelper in WPF.
Use the SystemMediaTransportControls instance as described on [2].
I would like to create a ScreenCaptureLib.dll which is intended to be built for Universal Windows.
We already have the following using Windows.Forms:
https://github.com/ShareX/ShareX/tree/master/ShareX.ScreenCaptureLib
Obviously none of the Windows Forms code does not work and I would like some pointers in the right direction to get started.
You may follow the official document for Record the screen with ScreenCapture, but please notice that:
The ScreenCapture API is only available on mobile devices.
And for now there is no API can be used directly to capture the screen on a desktop from an UWP app. However, as a workaround method, we can render the XAML tree to a bitmap, to do this, please refer to Capturing Snapshot in Windows 8.1 Store App.
You may also submit a request to add this new feature for developing through the Windows Feedback tool.
Update:
The ScreenCapture feature is only supported for mobile devices running Windows Phone 8.1. This API is not supported on Windows 10.
If anyone has developed WP apps before you know that you can't pass certification if your app stops music that is currently playing without the users consent.
I did see this question here which might have worked for WP7 apps but it apparently doesn't work for WP8. I assume it doesn't work because the WP8 OS doesn't support XNA (It is only backward compatible, and if you developed the app using 7.1).
Has anyone come across the solution for detecting background music in WP8.
I believe checking for MediaPlayer.GameHasControl is what you're looking for. Use that property and other members of MediaPlayer to satisfy application certification guidelines 6.5.1 Here's an end-to-end example of how # http://henry-chong.com/2012/02/pro-tip-including-background-music-for-your-windows-phone-app/
BTW, 6.5.x application certification requirements don't apply if your app is a Music+Video app. That's one way to address 6.5.1 :)
I believe that Microsoft.Xna.Framework.Media.MediaPlayer.State is still supported in Windows Phone 8 (MSDN source):
You can reference and use the following XNA Framework assemblies in
apps that target Windows Phone OS 8.0:
...
Microsoft.Xna.Framework.Media.dll
...
Im trying to create a media player (in C# .net 4.0) that will work on windows XP (SP3), vista and 7. Normally I would just go the easy way and use WPF's own MediaElement, but since that relies on Windows Media Player 10 or newer, that wont work as Windows XP SP3 may only have WPM9.
First I tried downloading Jerimiah Morill's WPF MediaKit sample application, but this used the EVR which wont show on my test machine (a Windows xp SP3 only with default codecs and default programs, plus the various .Net framework installations). I also downloaded the binaries and tore these apart, creating a new project only with reference to the DirectShow-dll and the bare minimums from the WPF mediakit, this time with no reference whatsoever to EVR. Still no luck. This i'm having a hard time understanding - should'nt even Windows XP be able to play movies using VMR stright out of the box?
I found some samples of media players where one of these works. This one is called DxPlay and uses directshow's graphbuilder, but is built in winforms, has some rather raw-looking code, and will not scale, seek, handle audio, and in general seems rather sketchy.
So, Is there any easy way to create a media player that will play on all the mentioned platforms without pushing WMP10+? I had high hopes for WPF MediaKit, but something is preventing it from playing on Windows XP SP3 (any solution to this would be very interesting).
Thank you very much in advance!
-ruNury
I would try to wrap VLC media player in your .Net project.
Here are some .Net projects that might help you:
http://vlcdotnet.codeplex.com/
http://sourceforge.net/projects/libvlcnet/
http://www.codeproject.com/Articles/109639/nVLC
MSDN suggest EVR (Enhanced Video Renderer) for video output in systems where it is supported: Windows Vista and later. With its introduction, its predecessors - Video Mixing Renderer filter (versions 7 and 9) were cut on smooth scaling of video. Video Mixing Renderer 7 is also less capable in terms of customization, however it consumes far less resources (does not use Direct 3D) and you can output way more videos at once.
Your standard solution here is to support both VMR and EVR output and use the latter starting Windows Vista, fall back to the former otherwise.
EVR is "unofficially" installed in Windows XP with .NET runtime and can be used with an instantiation trick: you the respective DLL is not COM registered and you cannot create an instance using CoCreateInstance API, however you succeed if you do CoLoadLibrary, DllGetClassObject and friends.
For C# development you typically consume DirectShow through DirectShow.NET Library.
I have C Static Library for Capturing Video from Camera.It uses Direct X to Interface Camera.
I wanted to create API in .Net C# for Capturing Video and do not want to use DirectX. The Target OS is Windows 8.Api Should be in Such way it should work on Both Desktop and Metro Mode of the Windows 8.
Any Help will be Appreciated.
As per comments above:
DirectX is at the heart of Windows 8 / Metro...
Several sessions on DirectX in Metro were held at BUILD - see http://www.buildwindows.com/Sessions/Tagged/DirectX
Regarding DirectX in Metro see for example http://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-766T
As the whole API (WinRT etc.) is not final right now it is sure not easy to port your code right now but from what I understand it will possible...
Another point: the Metro API is packaged as WinRT which is COM with several new aspects... this API is usable from .NET + native code (like C/C++)!