Windows Entertainment and Connected Home

How to organize, access and enjoy all of your media in and around your home

MSAS c# sink on Win 7?

  • rated by 0 users
  • This post has 44 Replies |
  • 6 Followers
Page 2 of 3 (45 items) 123
  •  

    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();
    }

    [ComImport, Guid("A70D81F2-C9D2-4053-AF0E-CDEA39BDD1AD"), InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface IMediaStatusSession
    {
      [
    DispId(1)]
     
    void MediaStatusChange(MEDIASTATUSPROPERTYTAG[] Tags, object[] Properties);

      [DispId(2)]
     
    void Close();
    }

    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:

    [ComVisible(false)]
    public enum MEDIASTATUSPROPERTYTAG
    {
      Application = 0xf001,
      ArtistName = 0x2018,
      CallingPartyName = 0x2029,
      CallingPartyNumber = 0x2028,
      CD = 0x2002,
      CurrentPicture = 0x201b,
      DiscWriter_ProgressPercentageChanged = 0x2030,
      DiscWriter_ProgressTimeChanged = 0x202f,
      DiscWriter_SelectedFormat = 0x202e,
      DiscWriter_Start = 0x202d,
      DiscWriter_Stop = 0x2031,
      DVD = 0x2001,
      Ejecting = 0x1010,
      DialogVisible = 0x100f,
    // Was Error
      FF1 = 0x100a,
      FF2 = 0x100b,
      FF3 = 0x100c,
      FS_DVD = 0x2010,
      FS_Extensibility = 0x202c,
      FS_Guide = 0x2011,
      FS_Home = 0x200e,
      FS_Music = 0x2012,
      FS_Photos = 0x2013,
      FS_Radio = 0x2025,
      FS_RecordedShows = 0x2015,
      FS_TV = 0x200f,
      FS_Unknown = 0x2016,
      FS_Videos = 0x2014,
      GuideLoaded = 0x201d,
      MediaName = 0x2017,
      MediaTime = 0x2007,
      MediaTypes = 0x2000,
      MSASPrivateTags = 0xf000,
      Mute = 0x1000,
      Next = 0x100d,
      NextFrame = 0x2021,
      ParentalAdvisoryRating = 0x202a,
      Pause = 0x1002,
      PhoneCall = 0x2027,
      Photos = 0x201a,
      Play = 0x1001,
      Prev = 0x100e,
      PrevFrame = 0x2022,
      PVR = 0x2003,
      Radio = 0x2023,
      RadioFrequency = 0x2024,
      Recording = 0x1006,
      RepeatSet = 0x1005,
      RequestForTuner = 0x202b,
      Rewind1 = 0x1007,
      Rewind2 = 0x1008,
      Rewind3 = 0x1009,
      Shuffle = 0x1004,
      SlowMotion1 = 0x201e,
      SlowMotion2 = 0x201f,
      SlowMotion3 = 0x2020,
      Stop = 0x1003,
      StreamingContentAudio = 0x2004,
      StreamingContentVideo = 0x2005,
      TitleNumber = 0x200c,
      TotalTracks = 0x2009,
      TrackDuration = 0x200a,
      TrackName = 0x2019,
      TrackNumber = 0x2008,
      TrackTime = 0x200b,
      TransitionTime = 0x201c,
      TVTuner = 0x2006,
      Unknown = 0,
      Visualization = 0x2026,
      Volume = 0x200d
    }

    Cheers,
    Andrew

  •  

    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

    without extender 

    extender started

    with extender

     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 started
    Idendity:Bart\pantarhei
    Sink.Initialize called
    Sink.CreateSession called
    Session.MediaStatusChange called
    Tag  FS_Home=True
    Session.MediaStatusChange called
    Tag  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 called
    Session.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?

    Cheers,
    Andrew

  •  

     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 Stick out tongue. 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!

    Cheers,
    Andrew

  •  

    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?

    Cheers,
    Andrew

  •  

     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 started
    ehmsas.exe Information: 0 : 10/27/2009 19:23:34 Session 63835064:63835064 Created
    ehmsas.exe Information: 0 : 10/27/2009 19:23:35 FS_Home=True
    ehmsas.exe Information: 0 : 10/27/2009 19:23:36 Volume=50
    ehmsas.exe Information: 0 : 10/27/2009 19:23:36 Mute=False
    ehmsas.exe Information: 0 : 10/27/2009 19:23:38 Volume=50
    ehmsas.exe Information: 0 : 10/27/2009 19:23:51 Error=True
    ehmsas.exe Information: 0 : 10/27/2009 19:23:52 Error=False
    ehmsas.exe Information: 0 : 10/27/2009 19:24:46 FS_Home=True
    ehmsas.exe Information: 0 : 10/27/2009 19:24:46 Volume=50
    ehmsas.exe Information: 0 : 10/27/2009 19:24:46 Mute=False
    ehmsas.exe Information: 0 : 10/27/2009 19:24:48 Volume=50
    ehmsas.exe Information: 0 : 10/27/2009 19:24:55 FS_Guide=True
    ehmsas.exe Information: 0 : 10/27/2009 19:25:04 Session 60504909:11454272 Created
    ehmsas.exe Information: 0 : 10/27/2009 19:25:04 FS_TV=True
    ehmsas.exe Information: 0 : 10/27/2009 19:25:04 TVTuner=True
    ehmsas.exe Information: 0 : 10/27/2009 19:25:04 MediaName=So You Think You Can Dance
    ehmsas.exe Information: 0 : 10/27/2009 19:25:04 MediaTime=7200
    ehmsas.exe Information: 0 : 10/27/2009 19:25:04 TrackNumber=39.1
    ehmsas.exe Information: 0 : 10/27/2009 19:25:04 TrackNumber=39.1
    ehmsas.exe Information: 0 : 10/27/2009 19:25:05 Stop=True
    ehmsas.exe Information: 0 : 10/27/2009 19:25:05 TrackNumber=39.1
    ehmsas.exe Information: 0 : 10/27/2009 19:25:05 Stop=True
    ehmsas.exe Information: 0 : 10/27/2009 19:25:05 TrackNumber=39.1
    ehmsas.exe Information: 0 : 10/27/2009 19:25:06 Play=True
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=3
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 TrackTime=2
    ehmsas.exe Information: 0 : 10/27/2009 19:25:07 MediaTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 TrackTime=3
    ehmsas.exe Information: 0 : 10/27/2009 19:25:08 MediaTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 TrackTime=4
    ehmsas.exe Information: 0 : 10/27/2009 19:25:09 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 MediaTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:10 TrackTime=5
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 MediaTime=8
    ehmsas.exe Information: 0 : 10/27/2009 19:25:11 TrackTime=6
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=8
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=9
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 TrackTime=7
    ehmsas.exe Information: 0 : 10/27/2009 19:25:12 MediaTime=9
    ehmsas.exe Information: 0 : 10/27/2009 19:25:13 MediaTime=9
    ehmsas.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.

    Cheers,
    Andrew

  •  

     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?

    Cheers,
    Andrew

  •  
    I have included both logs below.  I have removed the TrackTime and MediaTime entries to keep it short.

    In Vista I would get the following:

    ehmsas.exe Information: 0 : 06/18/2009 23:14:29 Sink started
    ehmsas.exe Information: 0 : 06/18/2009 23:14:29 Session 4032828 Created
    ehmsas.exe Information: 0 : 06/18/2009 23:14:29 FS_Home=True
    ehmsas.exe Information: 0 : 06/18/2009 23:14:29 Volume=50
    ehmsas.exe Information: 0 : 06/18/2009 23:14:30 Volume=50
    ehmsas.exe Information: 0 : 06/18/2009 23:14:38 FS_Guide=True
    ehmsas.exe Information: 0 : 06/18/2009 23:14:55 Session 33711845 Created
    ehmsas.exe Information: 0 : 06/18/2009 23:14:55 FS_TV=True
    ehmsas.exe Information: 0 : 06/18/2009 23:14:55 TVTuner=True
    ehmsas.exe Information: 0 : 06/18/2009 23:14:55 TrackNumber=10
    ehmsas.exe Information: 0 : 06/18/2009 23:14:56 ParentalAdvisoryRating=TV-14 DLV
    ehmsas.exe Information: 0 : 06/18/2009 23:14:56 Play=True
    ehmsas.exe Information: 0 : 06/18/2009 23:14:57 TrackTime=4496
    ehmsas.exe Information: 0 : 06/18/2009 23:14:57 MediaName=Outbreak
    ehmsas.exe Information: 0 : 06/18/2009 23:14:57 MediaLength=10800
    ehmsas.exe Information: 0 : 06/18/2009 23:15:11 Stop=True
    ehmsas.exe Information: 0 : 06/18/2009 23:15:11 Stop=True
    ehmsas.exe Information: 0 : 06/18/2009 23:15:13 Session 33711845 (33711845) Closed


    In Windows 7 I get:

    ehmsas.exe Information: 0 : 11/01/2009 22:49:55 Sink started
    ehmsas.exe Information: 0 : 11/01/2009 22:49:55 Session 63835064:63835064 Created
    ehmsas.exe Information: 0 : 11/01/2009 22:49:55 FS_Home=True
    ehmsas.exe Information: 0 : 11/01/2009 22:49:56 Volume=50
    ehmsas.exe Information: 0 : 11/01/2009 22:49:56 Mute=False
    ehmsas.exe Information: 0 : 11/01/2009 22:49:57 Volume=50
    ehmsas.exe Information: 0 : 11/01/2009 22:50:04 FS_Guide=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:06 Session 11454272:63835064 Created
    ehmsas.exe Information: 0 : 11/01/2009 22:51:06 FS_TV=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:06 TVTuner=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:06 MediaName=Sons of Anarchy
    ehmsas.exe Information: 0 : 11/01/2009 22:51:06 TrackNumber=54
    ehmsas.exe Information: 0 : 11/01/2009 22:51:06 TrackNumber=54
    ehmsas.exe Information: 0 : 11/01/2009 22:51:07 Stop=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:07 TrackNumber=54
    ehmsas.exe Information: 0 : 11/01/2009 22:51:07 Stop=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:07 TrackNumber=54
    ehmsas.exe Information: 0 : 11/01/2009 22:51:08 Play=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:25 FS_Guide=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:41 MediaName=Knocked Up
    ehmsas.exe Information: 0 : 11/01/2009 22:51:41 TrackNumber=46
    ehmsas.exe Information: 0 : 11/01/2009 22:51:42 Play=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:42 Stop=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:44 TrackNumber=46
    ehmsas.exe Information: 0 : 11/01/2009 22:51:44 Stop=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:44 FS_Unknown=True
    ehmsas.exe Information: 0 : 11/01/2009 22:51:44 Session 11454272 (11454272) Closed
  •  
    Any news on this bug?

    This adversely affects those with LCD displays in their HTPC's which display information from 7MC (such as Soundgraph iMon) - under previous versions of MC it would display the time within a programme and the total duration of the programme when watching live TV. Now it just displays the total time watching live TV and is practically useless due to this bug.

    I'm also worried by the fact that MSAS seems to have been deprecated in 7MC without any replacement identified as in case it indicates that Microsoft is no longer planning to support such devices in the future!

    Matthew
Page 2 of 3 (45 items) 123