Audioservice Plugins
An Audioservice Backend plugin adds an interface to a media player allowing Mycroft to play new types of media files or on remote devices.

AudioBackend

Each Audioservice plugin must implement a class derived from AudioBackend found in mycroft.audio.service. This class implements all basic commands and will be called by Mycroft. For complete specification see the docstrings for the class.
Apart from the expected commands (play, pause, etc), there are a couple of important methods to mention.
The supported_uris() method this is used to determine if the service backend can handle the given uri-type (https://, file://, etc). A basic implementation will return an iterable with uri types: ('file', 'http', 'https')
The playlist handling methods clear_list() and add_list(), of which the first removes all items from the current list, and the second appends a list of uri's to the list.

RemoteAudioBackend

If the audio backend that is implemented plays media on another device than the one Mycroft is running on this base class should be used. It is mainly used to sort generic playback queries defaulting to a local audio backend unless otherwise specified.

Instantiation

An audioservice can instantiate a number of backend objects so an instantiation function called load_service() needs to exist in the module. It will be called with the Mycroft audio configuration and a connection to the messagebus. The method should return a tuple with audio backends included in the file.
The load_service() function can also be used to scan the local network for things like chromecast and create an audioservice backend for each found device.
The basic layout of an Audioservice Plugin will be:
1
from mycroft.audio.service import AudioBackend
2
3
class MyAudioBackend(AudioBackend)
4
#lots of implementation here
5
[...]
6
7
8
def load_service(config, bus):
9
return (MyAudioBackend(config, bus), )
Copied!
Example Audioservices can be found here.

Entry point

To make the audioservice detectable as an Audioservice Backend Plugin, the package needs to provide an entry point under the mycroft.plugin.audioservice namespace.
1
setup([...],
2
entry_points = {'mycroft.plugin.audioservice': 'example_audiobackend = my_audiobackend'}
3
)
Copied!
Where example_audiobackend is the audio service module name for the plugin, my_audiobackend will be the audioservice module containing the load_service() function.
Note that this differs a fair bit from the TTS and STT Plugin entry points that point to a single class.
Last modified 1yr ago