1. developing plugins
  2. create your-first-plugin

Create your first plugin

If you are comfortable with Dart, Flutter and Hetu Script, you can start developing your first plugin. This guide will help you initialize a plugin project and write your first plugin.

spotube-plugin-template is a template repository for Spotube plugins. It’s a starting point with everything you need to get started with plugin development. You should use it to create your own plugin.

Simply clone or click “Use this template” button on the GitHub repository page to create a new repository.

$ git clone https://github.com/KRTirtho/spotube-plugin-template.git
$ cd spotube-plugin-template

After cloning the repository, you will find a file named plugins.json in the root directory. This file is crucial for Spotube to recognize your plugin. It looks like this:

{
  "type": "metadata",
  "version": "1.0.0",
  "name": "Alphanumeric plugin name with hyphens or underscore",
  "author": "Your Name",
  "description": "A brief description of the plugin's functionality.",
  "entryPoint": "plugin class name",
  "apis": ["webview", "localstorage", "timezone"],
  "abilities": ["authentication", "scrobbling"],
  "repository": "https://github.com/KRTirtho/spotube-plugin-template",
  "pluginApiVersion": "1.0.0"
}
PropertyDescription
typeThe type of the plugin, which is always metadata for Spotube plugins.
versionThe version of the plugin, following semantic versioning (e.g., 1.0.0).
nameThe name of the plugin
authorThe name of the plugin author.
descriptionA brief description of the plugin’s functionality.
entryPointThe name of the class that serves as the entry point for the plugin.
apisAn array of APIs that the plugin uses. This is used to determine which APIs are available to the plugin. Following APIs are available “webview”, “localstorage”, “timezone”
abilitiesAn array of abilities that the plugin has. This is used to determine which abilities the plugin has. Following abilities can be listed: “authentication”, “scrobbling”
repositoryThe URL of the plugin’s repository. This is used to display the plugin’s repository in the plugin manager.
pluginApiVersionThe version of the plugin API that the plugin uses. This is used to determine if the plugin is compatible with the current version of Spotube.

Change the values in the plugins.json file to match your plugin’s information.

There’s an example folder that contains a simple Flutter app that utilizes all the methods Spotube would call on your plugin. You can run this app to test your plugin’s functionality.

But first you need too compile the plugin to bytecode. You can simply do this using:

$ make

Make sure you’ve make command installed on your system and also must have the hetu_script_dev_tools package globally installed. After compiling the plugin, you can run the example app like any other Flutter app.

$ cd example
$ flutter run

Most of the buttons, will not work as they not yet implemented. You’ve to implement the methods in your plugin source code. We will cover how to implement the methods in the next section.