-
Notifications
You must be signed in to change notification settings - Fork 0
Create a new plugin
Warning
This program is licensed under the GNU General Public License v3.0 which may impose restrictions on the license of the plugins/extensions https://www.gnu.org/licenses/gpl-faq.en.html#GPLAndPlugins
The current guide assumes you have previous knowledge of the usage of c#, dotnet and visual studio. And assumes you have all installed. First create a class library
Warning SilverAudioPlayer relies on your plugins name to know if its compatible with the current runtime (OS). Please name it according to these following instructions.
If your plugin runs on linux and windows name it by using this SilverAudioPlayer.Any.<CompanyName.>[PluginName]
If your plugin is windows only name it by using this SilverAudioPlayer.Windows.<CompanyName.>[PluginName]
If your plugin is windows 10 only name it by using this SilverAudioPlayer.Windows10.<CompanyName.>[PluginName]
If your plugin is linux only name it by using this SilverAudioPlayer.Linux.<CompanyName.>[PluginName]
Right click Dependancies and click on manage nuget packages
In the window that appears search for silveraudioplayer.shared
click on it and click on install
click on ok
Visual studio will ask you to accept the license, by clicking I accept
you agree to the terms of the GPL license (READ IT).
You can now return to the Class1.cs file visual studio automatically created for you.
Rename it to something more appropriate
Now its time to choose an interface
-
IPlayProvider
for implementing new players (most of the time you should just implementINaudioWaveStreamWrapper
if a new player isn't needed to play that file) -
IMetadataProvider
for implementing new metadata providers (the things that read metadata from files/streams) -
IMusicStatusInterface
for implementing things that track/control playback (eg. discord rich presence/SMTC/Cd Art Display) -
IWakeLockProvider
for implementing ways to let the OS know NOT to go to sleep -
IPlayStreamProvider
for implementing ways of letting the user add new tracks from an external source (eg. internet radio streams, media servers (jellyfin, dlna, etc.))
Consider looking through the already implemented modules as a reference (copy the good aspects of them, not the bad ones)
This tutorial will focus on creating aIPlayStreamProvider
module but you may want to create a module of a different type for your usage.
ImplementIPlayStreamProvider
by adding: IPlayStreamProvider
after its name
Visual studio already knows what this interface requires so let it do the easy writing part for you
Change the modules name by changing
public string Name => throw new NotImplementedException();
public string Description => throw new NotImplementedException();
public WrappedStream? Icon => throw new NotImplementedException();
public Version? Version => throw new NotImplementedException();
public string Licenses => throw new NotImplementedException();
public List<Tuple<Uri, URLType>>? Links => throw new NotImplementedException();
public IPlayStreamProviderListner ProviderListner { set => throw new NotImplementedException(); }
public void ShowGui()
{
throw new NotImplementedException();
}
to
public string Name => "Example Plugin";
public string Description => "An example plugin";
public WrappedStream? Icon => null;
public Version? Version => typeof(ExamplePlugin).Assembly.GetName().Version;
public string Licenses => "ExamplePlugin - GPL-3.0"; //CHANGE THIS TO YOUR LICENSE
public List<Tuple<Uri, URLType>>? Links => new()
{
/*new Tuple<Uri, URLType>(
new Uri(
"https://github.com/yourusername/yourrepo"),
URLType.Code),*/ //Uncomment after filling
};
public IPlayStreamProviderListner ProviderListner { set => _ProviderListner=value; }
private IPlayStreamProviderListner _ProviderListner;
public void ShowGui()
{
//Do something cool
Process.Start("cmd.exe");
}
Export your module by adding [Export(typeof(IPlayStreamProvider))]
Your module should look like
Try it out by building your project and putting its dll in silveraudioplayer's directory (or its extensions subdirectory), then restart/launch silveraudioplayer.
After (re)launching click on the settings button.
Find your plugin
And click its use button
And voilà!
Let's try adding a song to the player's queue when the user clicks the Use button
public void ShowGui()
{
_ProviderListner.LoadSong(new WrappedHttpStream("https://archive.org/download/canyon_202011/CANYON.MID"));
}
Recompile your plugin, copy your dll to the SilverAudioPlayer directory (or its extensions subdirectory, you can create), and relaunch silveraudioplayer. It might take a second or so to show but that is one downside of the wrappedhttpstream And here it is, playing Dont trust me? Click on the blank square reserved for album art The song metadata will contain your wrappedhttpstream with its url set to the one you provided