Login
 
Archive
Links
Search
Blog List
There are no categories in this blog.
 
Sep 17

Written by: Jeremiah Morrill
9/17/2008 2:33 AM 

Finally got everything up on Codeplex.  Been very busy at work, but I'm happy to get this out to you all.  This should support "Any CPU" compilations, so 64bit is supported.  Of course you need 64bit DirectShow filters that any given media needs...So the sample application is set to x86 for now to provide the most compatibility.

Not all of Direct3D has been translated, just the stuff I needed.

http://www.codeplex.com/WPFMediaKit

Tags:

18 comment(s) so far...

Re: WPF MediaKit on Codeplex

Just gave it a quick test and it works just fine. Fast loading of my HD videos (all videos plays now).

I will testt it some more soon.

Good work Jer.

/Ken

By Ken on   9/17/2008 2:51 AM

Re: WPF MediaKit on Codeplex

Great!

EVR support is the next thing to tackle. I suspect even better performance with that!

By Jeremiah Morrill on   9/17/2008 2:57 AM

Re: WPF MediaKit on Codeplex

Also tested running 3 "MediaUriElement" in the same window and loading them with separate HD video's, none stopped or studder, when loading a new HD video. So you solve "multithread video" in the same UI. Great!


A "off topic" question. In VS2008 in develop mode I get error "Assembly 'WPFMediaKit' was not found. Verify that you are not missing an assembly reference."

How can I fix this, I get it on other 3:rd component also. I works when I compile and run the app, it's very irritating as I don't se anything in "design view". Yes, I did "Build All", and "Clean"...


/Ken

By Ken on   9/17/2008 3:21 AM

Re: WPF MediaKit on Codeplex

Not sure what that problem is. If you are talking about Cider in VS (the WPF designer), I just turn it off because it is truly worthless and has many issues with XAML in general.

-Jer

By Jeremiah Morrill on   9/17/2008 3:28 AM

Re: WPF MediaKit on Codeplex

Jer, how do I use "MediaUriPlayer" in pure code.

I try to add the "MediaUriPlayer" to a grid like this:

MediaUriPlayer _player1 = new MediaUriPlayer();
mediaGrid.Children.Add(_player1);


but get the error: "cannot convert from 'WPFMediaKit.DirectShow.MediaPlayers.MediaUriPlayer' to 'System.Windows.UIElement'"

Suggerstion on how to do? I need to add my player by code.


/Ken

By Ken on   9/17/2008 4:26 AM

Re: WPF MediaKit on Codeplex

You want to use a MediaUriElement. The DirectShow is all split up between "players" and "elements". The players are just the raw directshow stuff, isolated within its own thread and dispatcher. Elements are essentially a WPF wrapper for the players.

-Jer

By Jeremiah Morrill on   9/17/2008 4:33 AM

Re: WPF MediaKit on Codeplex

OK, got it working with

WPFMediaKit.DirectShow.Controls.MediaUriElement _player1 = new WPFMediaKit.DirectShow.Controls.MediaUriElement();

mediaGrid.Children.Add(_player1);
_player1.Source = new Uri(file);

But how do I hook it up with "WPFMediaKit.DirectShow.MediaPlayers.MediaSeekingPlayer" so I get "Duration" and other functions.

/Ken



By Ken on   9/17/2008 4:48 AM

Re: WPF MediaKit on Codeplex

MediaUriElement inherits from MediaSeekingElement just as MediaUriPlayer inherits from MediaSeekingPlayer. You want to look at the MediaPosition/MediaDuration property. That will allow you to seek and see the duration.

-Jer

By Jeremiah Morrill on   9/17/2008 4:55 AM

Re: WPF MediaKit on Codeplex

How do I connect by code "MediaSeekingElement and MediaUriPlayer" to MediaUriElement ?

/Ken

By Ken on   9/17/2008 5:50 AM

Re: WPF MediaKit on Codeplex

Not sure what you mean. If you are coding against the MediaUriElement, your are already using the MediaSeekingElement and MediaUriPlayer, but directly and indirectly.

/* Get position and duration */
double position = mediaUrlElement.MediaPosition;
double duration = mediaUriElement.MediaDuration;

/* goto half way */
mediaUriElement.MediaPosition = duration / 2;

By Jeremiah Morrill on   9/17/2008 6:05 AM

Re: WPF MediaKit on Codeplex

Sorry, didn't hade my thinking cap on...

"MediaDuration", yes. I was looking for just "Duration"

/Ken

By Ken on   9/17/2008 8:13 AM

Re: WPF MediaKit on Codeplex

The sample works really smooth (on HD also).

I'm going to test it in a real project next week.

I will inform you of the results.

Thanks for you great job.

Jordi

By Jordi on   9/17/2008 8:38 PM

Re: WPF MediaKit on Codeplex

Hello,

I test the WPFMediaKit and it crash. Error appeared when MediaKit cleaning resources (WPFMediaKit.dll!WPFMediaKit.DirectShow.MediaPlayers.MediaUriPlayer.FreeResources() Line 238 -> pointed to line: Marshal.FinalReleaseComObject(m_graph)) and I get pop-up with title "RaceOnRCWCleanUp".'

Why this happening?

-Jokkeri

By Jokkeri on   9/18/2008 6:21 AM

Re: WPF MediaKit on Codeplex

I really like this implementation so far. I have a small issue with the Loop behavior, though. It only checks whether or not to loop every 200ms, which causes a noticeable stutter when I'm looping a relatively short video. Lowering it to 15ms (so potentially >60 FPS) fixes the problem, but I need to carry around my own build of your product. Would you mind updating that value permanently, or making it modifiable?

Also, could you create an xml-ns entry for the assembly? Just being anal about the XAML stuff. :)

By Evan on   9/19/2008 11:24 AM

Re: WPF MediaKit on Codeplex

Thanks Evan!

The DispatcherTimer that runs ever n-ms, is kinda a hack at the moment. It's used right now to poll for events on the DShow graph. Normally you can just get events via WindProc messages, but for that I need an hWnd for each graph. I decided to keep it simple for now, but I may get the hWnd route in there sooner or later.

I can lower the default interval of the DispatcherTimer, does take the CPU down any at 15ms?

I'll look into adding an xml-ns. Good idea!

-Jer

By Jeremiah Morrill on   9/19/2008 5:52 PM

Re: WPF MediaKit on Codeplex

I'd strongly recommend to use the WndProc notify mechanism instead of continuous polling, which will inform you as soon as new messages are there. It's quite easy to get the window handle and assign a hook procedure to handle custom messages:

IntPtr windowHandle = new WindowInteropHelper(Window.GetWindow(this)).Handle;
HwndSource hwndSource = HwndSource.FromHwnd(windowHandle);
hwndSource.AddHook(MessageHook);

Then assign the WindowHandle to EventEx interface, with a message ID defined by you (WM_APP + x) and a IntPtr identifying the Graph instance:

EventEx.SetNotifyWindow(windowHandle, WM_GRAPHNOTIFY, instanceHandle);

Now you will be notified in the MessageHook procedure as soon as new events are available...

Keep up the good work! :)

Lukas

By Lukas on   9/20/2008 9:41 AM

Re: WPF MediaKit on Codeplex

Lukas's solution is ideal, but to answer your question, a 15ms timer doesn't noticeably impact anything. One thing you could do is have one timer for all running instances of your control, but I'm not sure that'd be really any easier than implementing Lukas's idea.

By Evan on   9/22/2008 8:08 AM

Re: WPF MediaKit on Codeplex

Already implemented the hWnd stuff in the latest codebase :) The timer just drives things like the media position now.

By Jeremiah Morrill on   9/22/2008 8:11 AM

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
  Minimize
Text/HTML Minimize
Copyright 2007
Downloaded from DNNSkins.com