MAS uses a provider system, which allows it to get it's data from a lot different data sources. If you want to implement such a provider for a new data source, such as the database of your MediaPortal plugin, follow this guide.
First you need to setup your project correctly. Create a new class library project and add a reference to the MPExtended.Services.MediaAccessService.Interfaces.dll file. You should also add a reference to System.ComponentModel.Composition. Projects should target .NET4 or newer, as the used plugin framework (MEF) is not available in older .NET versions.
Testing is a bit difficult. You've to copy the binary version of your library (.dll and optionally the .pdb) to the Extensions directory in MPExtended's installation directory (or you're whole project directory to the PlugIns directory if running MPExtended from source). Then restart the services and your plugin should be loaded. If you want to debug your plugin you can attach the debugger to the MPExtended process. Note that your plugin might not be loaded until you call a method where you specify your plugin as provider.
For this guide we'll use a movie plugin as example, but the other types (music, TV-show, filesystem and picture) aren't very different. Create a class that implements the IMovieLibrary interface. This is the class which is called by the MAS to get data from your plugin. You can get method stubs for everything you should implement by rightclicking IMovieLibrary and then selecting 'Implement interface'.
Then add the needed MEF export data for MAS to find your plugin correctly. Add these attributes to your plugin:
using System.CompontentModel.Composition; [Export(typeof(IMovieLibrary))] [ExportMetadata("Name", "Custom Movie Library")] [ExportMetadata("Id", 666)]
You should substitute Custom Movie Library with the name of your plugin, which will usually be a short description of where it gets it data from (for example Moving Pictures or MP Shares). The Id should be number that's unique across ALL providers that exist. All numbers below 100 are claimed by the MPExtended developers, so picking a random number above 100 should work. This is the ID that clients should specify for the provider parameter.
Aside from the standard methods such as GetAllMovies, which should return the data, there are also a few methods which are related to files. This is done to make it possible to use files that reside on a remote location, such as an FTP server. You're free to return a string in every format you want in the Path property of all objects. The GetFileInfo and GetFile methods are called with these strings as a parameter. GetFileInfo should return some metadata information about the file, while GetFile should return the content of the file. Set IsLocalFile to true in GetFileInfo if it's a file that can be accessed through the normal APIs (a local file or a mapped network drive), because that adds a performance boost to the streaming service.
The Search method is used in the search API. It should return a list of objects that match the text supplied in the parameter. Score is used to sort results on relevance, with 100 being the best result (you're sure that with the text the user you got the user really wanted this) and 0 being the worst result (it just matches but is probably not what the user was looking for). Implementing a smart search, for example by returning movies an actor played in when the name of an actor is entered, are bonus points.
GetExternalMediaInfo is meant to export the data to outside MPExtended. While some providers have meaningful IDs which can be used in other APIs, we've to make them up in other providers, and they aren't portable. This function allows the provider to export some other data instead which can be used as identifier. The main current user of this feature is WifiRemote, which uses this data to play movies/tvshows/musictracks, for which it calls the API of the plugins inside MediaPortal.