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
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
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.
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
located in ..\Program Files (x86)\Microsoft SDKs\Windows Media Center\v6.0\Tools
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.
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.
Initializing, Launching, and Uninitializing the Application
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.
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.
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.
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
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!!
- To get the TV, Vidioteka, Archive and radio the application uses http://www.iptv-distribution.net/cas/service.asmx
- To get Teleteka it uses new service api http://ivsmedia.iptv-distribution.net/ClientService.svc?wsdl
Media Center Markup Language Reference
Media Center Development Blog