The audio service handles playback and queueing of tracks.
mycroft-coredistribution of Mycroft includes a Playback Skill which can be used to control playback after it has been started. This means that playback only needs to be started in the Skill. Controlling playback can then be done through the Playback Skill.
First, import the
from mycroft.skills.audioservice import AudioService
Then in the
initialize()method of your Skill, instantiate an
self.audio_service = AudioService(self.bus)
#Other initialize code
AudioServiceinstance is created, you can start playback by simply calling the
play()method with a track URI:
or with a list of tracks
The play method has an optional second argument to further process the user's Utterance. Currently this can only be used to select backend (where you want to send the audio) but in the future it will be able to handle requests like
Hey Mycroft, play Hello Nasty by the Beastie Boys at half volume. We don't want to wake the neighbours
To use this feature the Utterance received from the intent service must be passed
def play_playlist_handler(self, message):
The default backend is still mpg123 for mp3 files which is very limited but is the most generally available or multiple platforms.
Included in this release there's also
VLC(a very general purpose media player)
mopidy(a common audio server in the Raspberry Pi community)
These haven't been extensively tested on the Mark 1 yet.
The audio service hooks into the PulseAudio controls and can mute playback of sound streams beyond Mycroft's control. This is currently deactivated by default but can be enabled by changing the
mycroft.confconfiguration found in
"play_wav_cmdline": "paplay %1 --stream-name=mycroft-voice",