-
Notifications
You must be signed in to change notification settings - Fork 810
How to build a Server Plugin
Please see our Development Policy before beginning development.
First install Emby Server, and get it up and running. Install Visual Studio 2017 along with the .NET Core SDK.
Emby Server runs on two different runtimes: .NET Core 2.0+, and Mono. The following instructions will show you how to build one plugin that will run on all platforms supported by Emby Server.
-
Create a .NET Standard class library project. This will create a Class1.cs file. Delete this and build the project. The process of building will save all changes to disk.
-
Once this is done, open up your .csproj file and replace the entire contents with the following:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="mediabrowser.server.core" Version="3.5" />
</ItemGroup>
</Project>
This will will add a reference to the Emby nuget package.
-
Build again to ensure Visual Studio has picked up the external changes.
-
Use Visual Studio to check for any non-beta updates to the Emby nuget package.
For these next steps, you may wish to refer to an example. The Roku bif plugin is a good example.
-
Create a class called PluginConfiguration, and have it inherit from MediaBrowser.Model.Plugins.BasePluginConfiguration.
-
Create a class called Plugin, and have it inherit from MediaBrowser.Common.Plugins.BasePlugin<T>, where T is the name of the PluginConfiguration class you just created. You will need to implement its constructor like so:
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer)
- Create a random GUID using visual studio's Create Guid tool under the Tools menu. In Plugin.cs, override the Id property, and return the guid you just created. This will be the Id for the plugin and can never be changed.
Important - If migrating an existing plugin solution from Visual Studio 2015, then the plugin Id value should come from the AssemblyGuid located in AssemblyInfo.cs of your 2015 project.
Right click the project -> Properties. Create a post-build event that will copy the assembly to the server's plugins directory. For example:
xcopy "$(TargetPath)" "%AppData%\Emby-Server\Plugins\" /y
Shutdown the server, rebuild your solution, and restart the server. At this point you should see your plugin in the Dashboard's Plugins menu.
To add real functionality to your plugin, you will need an entrypoint that can initialize and accept the various dependencies you may need in order to interact with the MB environment.
This is done by creating a class that implements the IServerEntryPoint interface. See Automatic Type Discovery for this and other types you can include in your plug-in. Its constructor can accept any number of injected dependencies - depending on what your plugin needs to access. See Dependency Injection.
If your plugin will be a premium plugin, see IRequiresRegistration in Other Interfaces.
In addition, use these Emby interfaces when applicable:
- IFileSystem
- IHttpClient
- INetworkManager
- IProcessFactory
- IZipClient
The quickest way to test code changes is to work without the debugger. If you do this, you can leave the server running at all times. Simply use the Rebuild command on your plugin project, and right click the server tray -> Restart Server. If that option is not visible you'll need to enable developer tools in the Dashboard under Advanced.
Emby Home | Latest News | Emby Downloads | Emby Community Forums | © 2019 Emby LLC
- Locating the Server
- Emby Connect
- Browsing the Library
- Latest Items
- Item Information
- Item Types
- Images
- Items by Name
- Web Socket
- Remote Control
- Live TV
- Playlists
- Parental Control
- Filtering
- Sync
- Playback Guidelines
- Audio Streaming
- Video Streaming
- HTTP Live Streaming (HLS)
- Subtitles
- Playback Check-ins