12 April 2012

Windows Media Center Plug-In

--Tatiana.golod 12:28, 14 October 2011 (EDT)
Existing solution: TFS/DefaultCollection/WMC plugin
Old solution: //depot/Code/CSharp/ConnecTV.Solution/
* Have to be VisualStudio 8 otherwise need to import templates and reinstall certificate

Contents

 [hide]

[edit]Building instructions

Building and registering the installers
1. Edit the Environment.bat for the correct paths, make sure you have gacutil.exe version 2 in order to register the installers
  • gacutil.exe version 2 comes with .NET SDK 2.0

The solution is configured to run PreBuild.bat and PostBuild.bat files for each project to register the installers them correctly
  • Build the solution twice!! the first time it will fail because the PreBuild.bat of each project try to unregister first and since nothing was registered yet it will fail.
So it goes like this:
Build all twice, if still fails
 1. Build project Jasmio.MediaCenter.Service, 
 2. Build Jasmio.MediaCenter.Service.RemotingInterfaces.Version1
 3. Build all again
2. Edit Build.reg

Building the installers - Manual
Build the library merge modules
Open command prompt
go to Jasmio.MediaCenter.Service\Setup
type Build 1.3.1 Debug
type Build 1.1.0 Debug
Certificate password: no12know

[edit]Building an installer instructions

2. Run Build 1.3.1 Debug in cmd (cd to Jasmio.MediaCenter.Service\Setup)
3. Run Build 1.1.1 Debug in cmd (cd to ConnecTV.MediaCenter\Setup)
(you'll get about 8 warnings, but no errors hopefully)
If it's worked, there should now be a couple of installers in the projects Debug output directory.

[edit]Debugging

To enable the debugging follow instructions in the documentaion SDK (Windows_Media_Center_SDK.chm)
Attaching a Debugger to a Windows Media Center Application using Visual Studio
  • To enable the registry variables for debug you can run
EnableAddInLaunchDebugging_False.reg
EnableErrorDetails_True.reg
located in ..\Program Files (x86)\Microsoft SDKs\Windows Media Center\v6.0\Tools

[edit]Strong names

Windows Media Center loads only locally-stored assemblies, which reside in the GAC, it requires all assemblies have strong names.
The following is the minimum information required to create a strong-named assembly:
  • Assembly title in plain text.
  • Assembly version number.
  • Cryptographic key-pair file used to digitally sign the assembly.
The Strong Name tool (sn.exe) included with the .NET Framework 2.0 SDK can also be used to create a strong name key file.

[edit]Threads in Windows Media Center

WMC applications are hosted in an individual ehExtHost.exe process. (Applications running on prior versions of WMC ran concurrent with the WMC process (ehShell.exe) in their own application domain.) WMC runs each background application in a separate thread, and the application can create as many threads as it needs. Because foreground threads can prevent the application from terminating properly, a multithreaded application should use background threads whenever possible by setting the thread IsBackground property to true.
  • An application can create as many threads as it wants. However, the WMC object model is single-threaded. You cannot construct a ModelItem or raise change notifications from a thread other than the main application thread. Most of the methods in the Microsoft.MediaCenter.UI namespace can only be called from the main application thread, with the exception of the methods in the Application class.
  • The methods in the Microsoft.MediaCenter.TV.Epg and Microsoft.MediaCenter.TV.Scheduling namespaces can be called on any thread or on as many as needed. Events are called back on the same thread as you called them from.

[edit]Initializing, Launching, and Uninitializing the Application

Project: Jasmio.MediaCenter.UI
Class: Experience
Must implement two interfaces: IAddInModule and IAddInEntryPoint.
  • IAddInModule exposes the Initialize and Uninitialize methods.
Calls flow:
1. IAddInModule.Initialize is the first method when it loads the application.
2. IAddInEntryPoint.Launch method, passing an instance of the AddInHost object to the application. This object lets the application access  
to retrieve information about WMC. The AddInHost object is valid only until the Launch method returns. Therefore an application must make all   
calls to the Windows Media Center APIs within the context of the Launch method. 
* After calling the Launch method, if you do not use the host object, the object could be released because .NET Remoting releases objects      
 every five minutes if they are not used. To avoid this, use the host object or use the objects within five minutes.
Terminating the Application
Before terminating an application, WMC calls the application's IAddInModule.Uninitialize method and then briefly waits for the application to save its state, terminate any threads it created, and free any other system resources that it may have allocated. If the application's Uninitialize method does not return quickly enough, it unloads the application's application domain, terminating the application.
  • You should assume that your application can be interrupted at any time. Design the application to perform lengthy operations in small steps, saving its state after each step if necessary.
  • If your application needs a more deterministic environment, you should implement the application as an executable program that runs outside of WMC and use a helper application to manipulate the Windows Media Center aspects of the application.

[edit]Playing Media

Project: ConnecTV.MediaCenter
Class: ConnecTVExperience
Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment
Enables applications to retrieve device information, gain access to disc changers, and control various aspects of WMC. The MediaCenterEnvironment class provides information about WMC, including its current capabilities and version number. For example, an application can use this class to display dialog boxes, play media, navigate to particular locations in WMC, and so on.

[edit]Markup

Defines a UI—how it appears visually, how it behaves, and how it interacts with code/data objects.
MCML separates code and data from UI logic. All UI development is done using MCML and is bound to data via rich binding mechanisms. All data and code are strictly non-visual.
The MCML files are embedded in the Resources.
Data binding performed in MCML, most object paths are evaluated at UI build time and their result values are set on the associated properties. However, some tags hold on to the object path and will re-evaluate it at runtime when needed.
  • ObjectName is always refers to a named object within the scope of the UI.

[edit]Developing Notes

MainPage.mcml defines a single page and serves as the container for the individual views. The data binding also occurs at this page.
ConnecTV.MediaCenter.View.ConnecTVSettings - settings class
All the logs are in ApplicationDataPath (C:\ProgramData\IPTV Distribution\)
Debug log:  C:\ProgramData\IPTV Distribution\IPTV Plug-in for Media Center\Debug.log
Settings (such as available packages for the user) are loaded from the settings file located in System.Environment.SpecialFolder.CommonApplicationData
Settings file C:\ProgramData\IPTV Distribution\IPTV Plug-in for Media Center\Settings.xml
Cache Files
C:\ProgramData\IPTV Distribution\IPTV Plug-in for Media Center\Cache
The localization files are copied to the:
C:\Program Files\IPTV Distribution\IPTV Plug-in for Media Center\Resources\Localization
the first time the application builds, so in order to see changes to the strings, change the appropriate file manually!!


Vianet services:
(\\10.0.0.42\e$\Inetpub\iptv-distributionApplications\cas\App_Code)
(\\10.0.0.42\e$\Inetpub\iptv-distributionApplications\IVsMedia)

[edit]Additional help

Media Center Markup Language Reference
http://msdn.microsoft.com/en-us/library/windows/desktop/bb189388.aspx
http://msdn.microsoft.com/en-us/library/bb189729
Media Center Development Blog
http://mediacenterdev.blogspot.com/2007/02/thinking-and-transferring-data-in-mcml.

Develop Media Center Addons

Short notes!!



Preparation of the environment

Should have Visual Studio 2008
1. Download and Install the Windows Media Center Software Development Kit from
http://www.microsoft.com/downloads/details.aspx?familyid=a43ea0b7-b85f-4612-aa08-3bf128c5873e&displaylang=en. 
2. Download and Install GUIDGEN.EXE from (if you don't have it in VisualStudio tools)
http://www.microsoft.com/downloads/details.aspx?familyid=94551f58-484f-4a8c-bb39-adb270833afc&displaylang=en. 
3. Download and install the latest build of WiX v3.0 (Wix3.msi) from
http://wix.sourceforge.net/downloadv3.html.


Build the add-on

The addon have to be registered with WMC and in GAC! In order to make a change you have to unregister it first and then to register again.
Also register it with  Windows Media Center ( %windir%\ehome\RegisterMCEApp.exe) 

Steps to switch to Canadian EPG in Windows Media Center

1) Install or check if it is installed HD HomeRun from
http://www.silicondust.com/support/hdhomerun/downloads/
2) Run EnableATSCandQAM.bat
3) Run USGuide.bat and select 4 (Toronto)
4) In WMC - >Tasks - >Settings -> TV -> TV Signal -> Setup TV Signal -> Select CANADA, M2N 6P4

How to Get EPG from WMC

1) Find C:\ProgramData\Microsoft\eHome\mcepg2-0.db
2) Build the WMC Addon with code from
http://social.msdn.microsoft.com/Forums/en/netfx64bit/thread/ea979075-f602-475d-b485-3a4f787dcb70 to 
http://experts.windows.com/frms/windows_entertainment_and_connected_home/f/25/p/79249/481843.aspx
  • Note: the EPG also saved in MXF File. More info:

Search This Blog

Total Pageviews