You don't need to add ehMsas.exe as a reference - as long as you add the following to your project as the interfaces are COM interfaces. Just add the following to your project:
[ComImport, Guid("075FC453-F236-41DA-B90D-9FBB8BBDC101"), InterfaceType(ComInterfaceType.InterfaceIsDual)]internal interface IMediaStatusSink{ [DispId(1)] void Initialize(); [DispId(2)] IMediaStatusSession CreateSession(); }
[
With these you won't need the Interop file. Try that and see if it resolves your problem.
Cheers,Andrew
Just in case you don't have it either, here is MEDIASTATUSPROPERTYTAG:
Hello Andrew,
i removed the reference and implemted the sink as you proposed. but the behavior is the same. the extender starts and and another ehmsas ghost process spawns. but the extender isn't sending any events. here are two screnshots of the processes:
without extender
extender started
in the sink constructor i'm writing the current principal to a file. if the sink is started for the MC itself i have this output:
Constructor: Sink startedIdendity:Bart\pantarheiSink.Initialize calledSink.CreateSession calledSession.MediaStatusChange calledTag FS_Home=True Session.MediaStatusChange calledTag FS_Music=True
and so on
now i thought if the extender connects i'll get the same result with something like:
Constructor: Sink started Idendity: Bart\Mcx1-BART Sink.Initialize called Sink.CreateSession calledSession.MediaStatusChange called Tag FS_Home=True
But nothing happens. i know it's hard to guess what's wrong here. but i hope you have another idea what i'm doing wrong.
regards
For Process Explorer, make sure you're running it elevated so you can see the contents of the ehMSAS session running on the extender.
From the log you're getting, it looks like MSAS is starting correctly on the extender, and is loading your sink. Just to check you realise, an ehMSAS process is created for each ehShell process - so it's not a "ghost" process if that's what you meant, it's the process that provides the media state for the extender.
Can you check that you have the AlwaysUseFPD registry entry set correctly?
damn. it was my fault. the sink produced an error on extender connection. took a while to realize that. it's working now.
thx for all you help.
This is a nice informative thread on MSAS and Win7. I wondered about the deprecation notice in the SDK too and now that is answered. I have not done C++ since Borland in college . Is there anywhere to get an already compiled MSAS DLL to configure and have a simple C# programmer like me hook into the media status event?
You don't need any C++ to write a sink to get media state events - simply creating a C# assembly that implements the two interfaces described in the thread, and register with MSAS using the registry entries described in the thread, and you're good to go!
Has anyone else noticed that in Windows 7 the MSAS medialength and mediatime tags aren't passing the correct data? They work fine for Recorded TV but in Live TV MediaTime starts at 1 when you start watching live TV and MediaLength is passing the same value as MediaTime. It then increments until Live TV is stopped rather than passing the data for the next program.
Are you saying that this is different from how Vista Media Center did it, or just that it doesn't make sense?
It was correct in Vista. For instance in Vista lets say I started watching a 1 hour show on Live TV 15 minutes in. The MediaTime (total time) tag would equal 3600 and the TrackTime (running time) tag would equal 900. In Windows 7 the MediaTime and TrackTime would both equal 1 and both would increment from there. If I stop watching the show and then start watching it again the tags reset to 1 again. My synch created a log of all tag changes, here is an exerpt:
ehmsas.exe Information: 0 : 10/27/2009 19:23:34 Sink startedehmsas.exe Information: 0 : 10/27/2009 19:23:34 Session 63835064:63835064 Createdehmsas.exe Information: 0 : 10/27/2009 19:23:35 FS_Home=Trueehmsas.exe Information: 0 : 10/27/2009 19:23:36 Volume=50ehmsas.exe Information: 0 : 10/27/2009 19:23:36 Mute=Falseehmsas.exe Information: 0 : 10/27/2009 19:23:38 Volume=50ehmsas.exe Information: 0 : 10/27/2009 19:23:51 Error=Trueehmsas.exe Information: 0 : 10/27/2009 19:23:52 Error=Falseehmsas.exe Information: 0 : 10/27/2009 19:24:46 FS_Home=Trueehmsas.exe Information: 0 : 10/27/2009 19:24:46 Volume=50ehmsas.exe Information: 0 : 10/27/2009 19:24:46 Mute=Falseehmsas.exe Information: 0 : 10/27/2009 19:24:48 Volume=50ehmsas.exe Information: 0 : 10/27/2009 19:24:55 FS_Guide=Trueehmsas.exe Information: 0 : 10/27/2009 19:25:04 Session 60504909:11454272 Createdehmsas.exe Information: 0 : 10/27/2009 19:25:04 FS_TV=Trueehmsas.exe Information: 0 : 10/27/2009 19:25:04 TVTuner=Trueehmsas.exe Information: 0 : 10/27/2009 19:25:04 MediaName=So You Think You Can Danceehmsas.exe Information: 0 : 10/27/2009 19:25:04 MediaTime=7200ehmsas.exe Information: 0 : 10/27/2009 19:25:04 TrackNumber=39.1ehmsas.exe Information: 0 : 10/27/2009 19:25:04 TrackNumber=39.1ehmsas.exe Information: 0 : 10/27/2009 19:25:05 Stop=Trueehmsas.exe Information: 0 : 10/27/2009 19:25:05 TrackNumber=39.1ehmsas.exe Information: 0 : 10/27/2009 19:25:05 Stop=Trueehmsas.exe Information: 0 : 10/27/2009 19:25:05 TrackNumber=39.1ehmsas.exe Information: 0 : 10/27/2009 19:25:06 Play=Trueehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:07 TrackTime=2ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:08 TrackTime=3ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:09 TrackTime=4ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:10 TrackTime=5ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=8ehmsas.exe Information: 0 : 10/27/2009 19:25:11 TrackTime=6ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=9ehmsas.exe Information: 0 : 10/27/2009 19:25:12 TrackTime=7ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=9ehmsas.exe Information: 0 : 10/27/2009 19:25:13 MediaTime=9ehmsas.exe Information: 0 : 10/27/2009 19:25:13 MediaTime=9
You can see that initially the MediaTime tag is correct but then resets to 3. On a Vista machine you would only see one MediaTime change which would be correct and the MediaTime values would be where you are currently at in the show.
This has now been submitted as a bug.
Thanks, I have also noticed that it doesn't report the parental rating anymore.
Have you got a trace of what it used to do vs. now that I can use for bug logging?