scripts/mycroft/audio/services/__init__.py
Go to the documentation of this file.
1 # Copyright 2017 Mycroft AI Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 from abc import ABCMeta, abstractmethod
16 
17 
19  """
20  Base class for all audio backend implementations.
21 
22  Args:
23  config: configuration dict for the instance
24  bus: Mycroft messagebus emitter
25  """
26  __metaclass__ = ABCMeta
27 
28  def __init__(self, config, bus):
30  self.supports_mime_hints = False
31 
32  @abstractmethod
33  def supported_uris(self):
34  """
35  Returns: list of supported uri types.
36  """
37  pass
38 
39  @abstractmethod
40  def clear_list(self):
41  """
42  Clear playlist
43  """
44  pass
45 
46  @abstractmethod
47  def add_list(self, tracks):
48  """
49  Add tracks to backend's playlist.
50 
51  Args:
52  tracks: list of tracks.
53  """
54  pass
55 
56  @abstractmethod
57  def play(self, repeat=False):
58  """
59  Start playback.
60 
61  Args:
62  repeat: Repeat playlist, defaults to False
63  """
64  pass
65 
66  @abstractmethod
67  def stop(self):
68  """
69  Stop playback.
70 
71  Returns: (bool) True if playback was stopped, otherwise False
72  """
73  pass
74 
75  def set_track_start_callback(self, callback_func):
76  """
77  Register callback on track start, should be called as each track
78  in a playlist is started.
79  """
80  self._track_start_callback = callback_func
81 
82  def pause(self):
83  """
84  Pause playback.
85  """
86  pass
87 
88  def resume(self):
89  """
90  Resume paused playback.
91  """
92  pass
93 
94  def next(self):
95  """
96  Skip to next track in playlist.
97  """
98  pass
99 
100  def previous(self):
101  """
102  Skip to previous track in playlist.
103  """
104  pass
105 
106  def lower_volume(self):
107  """
108  Lower volume.
109  """
110  pass
111 
112  def restore_volume(self):
113  """
114  Restore normal volume.
115  """
116  pass
117 
118  @abstractmethod
119  def seek_forward(self, seconds=1):
120  """
121  Skip X seconds
122 
123  Args:
124  seconds (int): number of seconds to seek, if negative rewind
125  """
126  pass
127 
128  @abstractmethod
129  def seek_backward(self, seconds=1):
130  """
131  Rewind X seconds
132 
133  Args:
134  seconds (int): number of seconds to seek, if negative rewind
135  """
136  pass
137 
138  def track_info(self):
139  """
140  Fetch info about current playing track.
141 
142  Returns:
143  Dict with track info.
144  """
145  ret = {}
146  ret['artist'] = ''
147  ret['album'] = ''
148  return ret
149 
150  def shutdown(self):
151  """ Perform clean shutdown """
152  self.stop()
153 
154 
156  """ Base class for remote audio backends.
157 
158  These may be things like Chromecasts, mopidy servers, etc.
159  """
160  pass


mycroft_ros
Author(s):
autogenerated on Mon Apr 26 2021 02:35:40