forked from MycroftAI/mycroft-core
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/ovos_plugin_manager #1
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,182 +1,2 @@ | ||
# Copyright 2017 Mycroft AI Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
"""Definition of the audio service backends base classes. | ||
from ovos_plugin_manager.templates.audio import AudioBackend, RemoteAudioBackend | ||
|
||
These classes can be used to create an Audioservice plugin extending | ||
Mycroft's media playback options. | ||
""" | ||
from abc import ABCMeta, abstractmethod | ||
|
||
|
||
class AudioBackend(metaclass=ABCMeta): | ||
"""Base class for all audio backend implementations. | ||
|
||
Args: | ||
config (dict): configuration dict for the instance | ||
bus (MessageBusClient): Mycroft messagebus emitter | ||
""" | ||
|
||
def __init__(self, config, bus): | ||
self._track_start_callback = None | ||
self.supports_mime_hints = False | ||
self.config = config | ||
self.bus = bus | ||
|
||
@property | ||
def playback_time(self): | ||
return 0 | ||
|
||
@abstractmethod | ||
def supported_uris(self): | ||
"""List of supported uri types. | ||
|
||
Returns: | ||
list: Supported uri's | ||
""" | ||
|
||
@abstractmethod | ||
def clear_list(self): | ||
"""Clear playlist.""" | ||
|
||
@abstractmethod | ||
def add_list(self, tracks): | ||
"""Add tracks to backend's playlist. | ||
|
||
Args: | ||
tracks (list): list of tracks. | ||
""" | ||
|
||
@abstractmethod | ||
def play(self, repeat=False): | ||
"""Start playback. | ||
|
||
Starts playing the first track in the playlist and will contiune | ||
until all tracks have been played. | ||
|
||
Args: | ||
repeat (bool): Repeat playlist, defaults to False | ||
""" | ||
|
||
@abstractmethod | ||
def stop(self): | ||
"""Stop playback. | ||
|
||
Stops the current playback. | ||
|
||
Returns: | ||
bool: True if playback was stopped, otherwise False | ||
""" | ||
|
||
def set_track_start_callback(self, callback_func): | ||
"""Register callback on track start. | ||
|
||
This method should be called as each track in a playlist is started. | ||
""" | ||
self._track_start_callback = callback_func | ||
|
||
def pause(self): | ||
"""Pause playback. | ||
|
||
Stops playback but may be resumed at the exact position the pause | ||
occured. | ||
""" | ||
|
||
def resume(self): | ||
"""Resume paused playback. | ||
|
||
Resumes playback after being paused. | ||
""" | ||
|
||
def next(self): | ||
"""Skip to next track in playlist.""" | ||
|
||
def previous(self): | ||
"""Skip to previous track in playlist.""" | ||
|
||
def lower_volume(self): | ||
"""Lower volume. | ||
|
||
This method is used to implement audio ducking. It will be called when | ||
Mycroft is listening or speaking to make sure the media playing isn't | ||
interfering. | ||
""" | ||
|
||
def restore_volume(self): | ||
"""Restore normal volume. | ||
|
||
Called when to restore the playback volume to previous level after | ||
Mycroft has lowered it using lower_volume(). | ||
""" | ||
|
||
def get_track_length(self): | ||
""" | ||
getting the duration of the audio in milliseconds | ||
""" | ||
|
||
def get_track_position(self): | ||
""" | ||
get current position in milliseconds | ||
""" | ||
|
||
def set_track_position(self, milliseconds): | ||
""" | ||
go to position in milliseconds | ||
|
||
Args: | ||
milliseconds (int): number of milliseconds of final position | ||
""" | ||
|
||
def seek_forward(self, seconds=1): | ||
"""Skip X seconds. | ||
|
||
Args: | ||
seconds (int): number of seconds to seek, if negative rewind | ||
""" | ||
|
||
def seek_backward(self, seconds=1): | ||
"""Rewind X seconds. | ||
|
||
Args: | ||
seconds (int): number of seconds to seek, if negative jump forward. | ||
""" | ||
|
||
def track_info(self): | ||
"""Get info about current playing track. | ||
|
||
Returns: | ||
dict: Track info containing atleast the keys artist and album. | ||
""" | ||
ret = {} | ||
ret['artist'] = '' | ||
ret['album'] = '' | ||
return ret | ||
|
||
def shutdown(self): | ||
"""Perform clean shutdown. | ||
|
||
Implements any audio backend specific shutdown procedures. | ||
""" | ||
self.stop() | ||
|
||
|
||
class RemoteAudioBackend(AudioBackend): | ||
"""Base class for remote audio backends. | ||
|
||
RemoteAudioBackends will always be checked after the normal | ||
AudioBackends to make playback start locally by default. | ||
|
||
An example of a RemoteAudioBackend would be things like Chromecasts, | ||
mopidy servers, etc. | ||
""" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this deserve an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe, there is one in the upstream tflit repo already, happens in some platforms due to some mismatch with post release version of the wheel it tries to download or something during setup.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to make sure we remember to remove this when upstream gets fixed, though it's not a big deal just for automation