OrientationThis will just give you a brief view of whats included in the template.
First of all extract the contents of the RAR file to a suitable directory.
Template ContentsYou should find three folders
This folder contains what will eventually be installed on the target system.
All files which are in here will be picked up by the innosetup script. You can add and remove files as you wish.
[li]
Installation[/li]
This contains an InnoSetup script which will allow you to create a setup program
which will be run by the end user to install your plugin on there system.
(Of course you can distribute your plugin in any fashion you like, this is just a good way to do so).
If you don't use Innosetup you will have to create REG files which do what the innosetup script does for you.
Innosetup also compresses everything into one neat .EXE file.
The Installation folder also contains a folder called Output. This is where the installation Setup.exe will be placed.
[li]
MC_CSPlugin_Template[/li]
This contains the source code which produces the plugin. It includes a soloution and a project which can be opened in both #Develop 2.0 or Visual Studio 2005.
[/list]
Source CodeOpen up the soloution file in your chosen development environment.
I'm using Visual Studio 2005 so you'll have to find the counter parts for the
environment your using.
ClassesIn the Soloution Explorer you will see a class called MainInterface.
There is only once class at present. If you want more you can add them at a later date.
Main Interface Partial ClassesClick the plus symbol next to MainInterface.cs on the Soloution Explorer.
You can see that this class is split into partial classes, spltting the form designer code
from the user code. (This is a new feature in C# 2.0)
Main Interface PanelDouble click on MainInterface. It will open up a form designer, and display a Panel.
This panel is the main Window area for the plugin. You can place any controls
you wish here.
Main Interface Source CodeIf you now switch to code view by pressing F7 you will see the main code
for the class, but not the designer code. It's not doing much at present.
So the class is just 65 lines long.
I've used Regions to split the class up into the following sections
These are the using statements which tell the compiler which libraries are needed.
[li]
Interop Program ID Registration[/li]
This is for Interop Registration. This is very important and discussed later.
[li]
Attributes[/li]
This contains the private attributes in use by our class. Currently there is only one. This is the reference to the
Media Center Interface which allows us to control and access Media Center using the SDK.
[li]
Constructor[/li]
This is the main constructor for the plugin. This creates the GUI (Windows Forms)controls. I think I need to check up on when this is first called...
[li]
Media Center Initialisation[/li]
Media Center calls this function when the plugin is created.
It is here that we set our Media Center Reference, so that we can permenantly access it.
[/list]
Register for COM InteropInformationIn order for the plugin to be registered with Media Center two things must occur.
First of all the appropriate registry settings must be created which tell Media Center
that a plugin exists, information about that plugin such as who made it and what it's called,
and also the ProgID which Media Center will use to access the plugin.
Secondly the plugin must be registered in such away that the registry can correlate the
progID to a specific DLL. This is all related to the Component Object Model (COM).
In order for a .NET assembly to be registered in this way, it must use something called
COM Interop. To allow Media Center to see the plugin we must Register the plugin for COM Interop
The method of doing this normally is through a command line utility called REGASM.
The Innosetup script does this when a plugin is being installed.
When developing Visual Studio does allow you to Register the plugin everytime it is rebuilt.
The template comes with this setting turned on.
The Media Center InterfaceJRiver provide a type library file which provides the interface to Media Center.
This has been wrapped into an assembly file. (How this is done can be seen in my
Busybox.NET tutorial).
As part of the template there is provided a ready made wrapped assembly file - MediaJukebox.dll
The plugin also already includes all the necassery references to this DLL.
InnoSetup ScriptThe inno setup script Contains the following sections
This area contains all the strings that are displayed during the setup process
Change these to suite your plugin, and information about yourself.
It also contains the default Directory for the plugin which is currently
..\Program Files\J River\Media Center 11\Plugins\TemplatePlugin[li]
Languages[/li]
Language for setup, defaults to English, play with this as need be.
[li]
Files[/li]
The files that will be installed. This defaults to all the files and folders that are contained
within the "Build Files" directory.
[li]
Icons[/li]
The icons that will be placed in the Start Menu, defaults to just the uninstall icon
since the plugins cannot usually be run on their own.
[li]
Registry[/li]
The registry entries that must be installed. These are particulariliy important because
they tell Media Center that the plugin exists, what it is called, and how it can be found.
Most of the values are just information that is provided about the plugin when viewed
in the plugin manager.
Two values which are more critical are the ProgID and the PluginMode.
The
ProgID represents the ID for the plugin by which COM finds the plugin.
It MUST match the ProgID that is contained within MainInterface within the source code of the plugin, in order for
the plugin to be found.
The
PluginMode specifys how the plugin should load on start up of Media Center. A value of 1 means
that the plugin loads once and will remain open even when the interface is not shown.
A value of 0 means the plugin will reload every time the user opens the interface, and close when the user
moves away from it.
[li]
Run[/li]
During installation of the plugin, it must be registered for COM interop, as detailed above in the
section Register For COM Interop. The run section has a REGASM command to do this. It does rely on the user
having the exact same version of the .NET framework. Any ideas on how this can be avoided
are appreciated.
[li]
UninstallRun[/li]
On Uninstall of the plugin we want it to be unregistered. This just performs a REGASM /unregister
on the plugin
[/list]