Creating a universal video player (XP, vista, 7) - c#

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.

Related

How to detect media playing with C#?

I would like to know how to detect if current windows is playing any kind of media (video, music, etc) similar to what energy settings do to decide if the computer can enter sleep/hibernate mode?
I'm trying to detect how long the computer is idle. I'm currently using the GetLastInputInfo from user32.dll but it just take in consideration the user input, but not if there is any media playing which should not consider the computer idle.
I tried to find C# APIs or native invocations but can't find the information. I'm using latest version of .NET Framework.
Generally speaking, programs don't declare that they are playing media - instead they call SetThreadExecutionState to tell Windows that the computer should not sleep.
That said - Windows 10 recently added support for programs to declare to the OS that they are currently playing media so that they're integrated with Windows' media controls (like how on iOS any program playing video or audio can be controlled from the Control Center).
Here's what appears on my screen when I nudge my volume control:
...however Chrome is being buggy here because I'm not actually playing any media in Chrome but it's telling Windows that it is.
I don't know what Windows API is used to set this - or which API is used to check it - but it isn't very widely used - even Windows' built-in Windows Media Player 12 doesn't use it.

How can I show an MP4 video inside a Winforms application without the need for installing missing codecs?

We're currenty building a little company presentation application for USB sticks that is used to display PDF files regardless of any PDF reader installed on the system. That works quite well, so we now also want to show videos directly inside the application. As we cannot ensure that the customers system is able to play the video file, I'd like to include everything that is neccessary to play the video regardless of the system configuration.
Before I reinvent the wheel - is there a preferred way to do so? Would another video format offer more possibilities? The target OS is supposed to be Windows XP up to Windows 8 and .NET 2.0. Is there any framework/assembly that I could use to become independent of any prerequisites on the target system? Thanks for your recommendations and thoughts on this!
Playing videos requires software to transform the video data into moving images. Unless you want to take on the mammoth task of writing your own MP4 decoder, you'll have to rely on what the user has installed.
Wikipedia lists Windows Media Player versions here. Version 12 is the only one to support MP4 out-of-the-box. That means your Windows XP and Vista users are going to need a third-party codec.

Support for XNA in WP8?

After watching a little bit of the summit keynote I kind of heard conflicting reports about it, but is it official that XNA is being dropped for WP8? I'm guessing since the future version of WP supports previous generation of apps that this is probably not true.
If it is though is using C# even an option for games or is C++ with DirectX the only way to go?
the official wp7dev twitter account had this to say too
"XNA Framework apps are fully supported in WP8. The new WP SDK will support building XNA Framework games for both WP7.x & for WP8"
https://twitter.com/wp7dev/status/215513026374270977
Personally given the lack of XNA updates or information and the lack of any Metro support on windows 8 I'm staying a little skeptical until I see an SDK and the publishing rules.
Mary Jo Foley had this to say about that:
Microsoft officials have said the XNA tools/runtime environment used primarily by game developers isn't supported on Windows 8. On Windows Phone 8, XNA is "supported," so existing Windows Phone games will run. But Microsoft's advice to phone developers going forward, just like it is for Windows 8, is to use native code, meaning C and C++, to write games.
As the public WP8 SDK is now available, I can confirm that you cannot develop XNA apps for the #WP8 platform directly. You can only target the WP7 platform with your XNA apps and they will run on WP8 devices just fine.
I'm sure it's too early to speculate on this at this point, we'll see when the SDK is released. But from what I've seen so far - I would say yes, XNA might not be officially supported WP8 and onwards (read - new features will probably only be available via the DirectX interface, but existing features will continue to be supported). However, according to this thread, games that use Monogame to run on Windows 8 metro will pass certification. So in one way or the other, the platform will not die.
Edit: I just noticed this tweet from Shawn Hargreaves: Windows Phone 8 runs all 7 apps including XNA ones. We're adding new features (native code, D3D) not taking away old ones
I've been working on and off on an XNA game that I had started with VS2010 & WP 7 SDK, and later upgraded to 7.5 (Mango). I loaded up that project in VS2012 and the WP8 SDK and it ran just fine, compiled with no errors and ran smoothly.
As previously stated, XNA projects in VS2012 and the WP8 SDK can only target the WP 7.1 platform. On the upside, all phones running WP 7.5, the upcoming 7.8 and WP8 will run your game without any issues. From that point of view, XNA is fully supported in the WP8 SDK, on WP8 devices, but these WILL NOT be WP8 projects.
By not being WP8 projects, the downside is that you CANNOT use WP8-exclusive features, such as:
In-app purchasing / micro-transactions (this one hurts XNA devs the
most)
Your games will always be 800x480 since you need WP8 projects to support higher resolutions. Your XNA games should automatically scale up when run on devices with a higher res
Exclusive WP8 networking features & APIs, including Bluetooth and NFC
Speech and voice recognition APIs
Your XNA game cannot register a protocol extension for app-to-app communications
New Live Tile templates
The dev highlights for WP8 are on the wpdev blog at http://blogs.windows.com/windows_phone/b/wpdev/archive/2012/11/05/windows-phone-8-developer-platform-highlights.aspx.

Image Capture in C#

I'm working on a home project that involves comparing images to a database of images (using a quadrant - or so - histogram approach). I wanted to know what my options are in regards to web cams or other image capture devices that:
Are easy to work with with the
Windows SDK (particularly
DirectShow, which I plan to use
with C#)
Have drivers for both
64-bit and 32-bit Windows Vista (and
Server 2008)
I'm asking primarily so I can avoid pitfalls that other people may have experienced with web cams and to see if there are other image capture devices (or C# usable APIs) available that I should look at. I suspect that any old web cam will do but I'd rather be safe than sorry.
If you only want images, many web cams support TWAIN -- you can use with .NET using this code
http://www.codeproject.com/KB/dotnet/twaindotnet.aspx
I'm doing something very similar with webcams and have found that logitech and Microsoft branded webcams work just fine with DirectShow.
I've also found that many NEW webcams don't support twain, and WIA support for doing live captures has been removed in Vista, and doesn't exist in 2000, so Directshow has been the only thing that seems to work reliably accross OS's.

Compact Framework : any Finger Friendly GUI?

i m developing a little tool on my Pocket PC using WM6 SDK but i would like to implement a finger friendly user interface (iphone-like).
So i m looking for a free .NET framework that offers the possibility to easily integrate a finger friendly interface for Windows Mobile 6 Pro .
Any ideas ?
EDIT : Finger friendly means big icons, big buttons , scrollable screens with a simple touch of the thumb... Because the Winforms in Compact framework are made for the stylus, not fingers !!
I know of no such interface API.
I would code such an interface from scratch, overriding Paint and mouse events. If you need more fancy drawing tools that compact framework provides, you should look for pinvoke to access GDI+.
You should really check out Resco's MobileForms Toolkit 2009.
I bet their controls are exactly what you are looking for. Plus they have a whitepaper and videos to show off the controls.
I am not sure it is what you are looking for (I didn't have time to examine it yet myself, but I definately intend to); this UI Framework looks interesting:
http://code.msdn.microsoft.com/uiframework
Check out the Fluid windows mobile controls available at http://fluid.codeplex.com/
This might be what you are looking for, and its open source.
Any current readers on this thread should check out SlideUI (http://www.devslide.com/products/slideui). It's a current (and supported) product which offers touch friendly (iphone-like) scrolling and controls.
I'm not entirely sure what you're asking here... Windows Mobile 6.0 Pro is touch-screen enabled, so you should simply have to create your project targeting the Windows Mobile 6.0 Pro (note, however, that your application will not be compatible with Windows Mobile 6.0 Standard devices).
I know exactly what you are talking about. All the .NET Controls are designed for the stylus. When you make them bigger for the finger, there is no guarantee they will respond well. Add to that every hardware devices sensitivity is different and its even harder.
I recently built an application attempting to incorporate some touch like functionality. it was a pain having hand code all this stuff.
The problem with a 3rd party library, as opposed as coming in Windows MObile is then everyone is designing their own library and navigation techiques. Hopefully MS will wise up on this front.
http://sites.google.com/site/nebowiki/
If you are developing finger friendly apps, your target device needs a process to handle finger input as opposed to the stylus. HTC devices (Such as the Kaiser, Mogul, Touch Pro, etc.) use TouchFlo for this purpose. There are a few different versions of TouchFlo and I'm not sure if there is an SDK, but you need to incorporate it into whatever you program. xda-developers.com will have lots of info about it.
It IS amazing that with WM6.1 Pro, .NET CF 3.5 and VS2008 that all we have available are the basic stylus-sized controls that are are spartan in the extreme. i.e., coyote-ugly. I'm about ready to chew my hand off rather than use them in an app.
So where is the third-party collection of controls that all WM developers are flocking to, to provide touch-friendly apps?
Ugly is truly the correct word for most (mine included) mobile win apps.
I am developing for an older piece of hardware with a mono screen which makes it even worse.
Take a look here:
http://www.windowsfordevices.com/news/NS9328208835.html
and here:
http://msdn.microsoft.com/en-us/library/dd630622.aspx
This is not free, but it is affordable - some of the screen shots are pretty nice looking:
http://www.basic4ppc.com/?gclid=CIiO1di1nJoCFRAhDQodYX8-9A
Anyway...sorry if this was just googledragging - maybe it had something you had missed.
--Joe
Finger Freindlyness is a result of the touch screen technology (capacitive screens are less accurate, but require zero pressure; resistive screens require physical pressure and are harder to swipe, flick, etc.)
With Windows Mobile 6.5, they have introduced a system gestures library (and if you'd rather not have to P/Invoke it, there is a sample wrapper on MSDN Code Gallery). Theoretically, it would be possible to write to this new library, and maybe emulate the gestures on pre-WM6.5 devices, if required.

Categories

Resources