-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add method for updating playback information from skills #2619
Add method for updating playback information from skills #2619
Conversation
Voight Kampff Integration Test Succeeded (Results) |
as mentioned in #2614 it would be nice to send this info to audio service, not only to common play, because skills (and other stuff connected to bus) request this info from here common_play needs this info for the gui, audio service needs this info to provide to the messagebus when requested I would just make (all) the audio services also listen to this message and update their info, or this method can emit a seconday message to update audioservice i like using Enum for status, but we need to think about serialization to json, it should be understandable to humans so i like using a string i think track length and current position should be added to the method |
Yes this doesn't cover the issue you describe in #2614, this is mainly to make the message that's currently being used an actual standard (or possibly not if the discussion deems this method not good enough). I have an initial idea for a solution for the issue you described and will make a PR showing that off as soon as I get another free hour or two to prepare it. For the enum I was thinking of using I will update this PR with the suggested additions. |
proposal class CPSTrackStatus(Enum):
DISAMBIGUATION = 1 # not queued for playback, show in gui
PLAYING = 2 # Skill is handling playback internally
PLAYING_AUDIOSERVICE = 3 # Skill forwarded playback to audio service
QUEUED = 4 # Waiting playback to be handled inside skill
QUEUED_AUDIOSERVICE = 5 # Waiting playback in audio service
BUFFERING = 6 # Incase it's an online source the buffering state or
STALLED = 7 # stalled state helps to know when to show the buffering ui
END_OF_MEDIA = 8 # helps to know if we want to do autoplay or something class CommonPlaySkill(MycroftSkill, ABC):
# (...)
def CPS_send_status(self, artist='', track='', album='', image='',
track_length="", current_position="",
status=CPSTrackStatus.DISAMBIGUATION, **kwargs):
data = {'skill': self.name,
'artist': artist,
'album': album,
'track': track,
'image': image,
'track_length': track_length,
'current_position': current_position,
'status': status
}
data = {**data, **kwargs} # Merge extra arguments
self.bus.emit(Message('play:status', data))
def CPS_send_tracklist(self, tracklist=None):
tracklist = tracklist or []
if not isinstance(tracklist, list):
tracklist = [tracklist]
for track in tracklist:
self.CPS_send_status(**track) |
Voight Kampff Integration Test Failed (Results) |
7161fca
to
8bc56d7
Compare
Just trying to get a better idea/understanding about what additional data methods are being proposed on CPS side for sending to the GUI in this discussion, as I would like to upgrade the current UI for playback skill to add support for a seekbar, thumbnail, background image and more controls like mute, repeat, autoplay and maybe a swipeable second page for searched results / playlist. on GUI side the Mycroft.AudioPlayer component has its own state and signal handlers, but it seems the playback skill that handles common play itself does not use the media player component, so assuming we want to handle seeking by voice "fast forward 10 seconds" and seek bar in the UI to sync graphically to that position, is the above data message going to be emitted on change/update of every key field like current position ? might be more related to playback skill itself that handles the ui, how does that interaction work in reverse for updating the data message, example on seeking physically on the ui ? |
Voight Kampff Integration Test Failed (Results) |
Regarding AudioService and CommonPlaySkill
Regarding GUI I see the GUI has having 3 swipeable pages: Currently Playing gui actions / intents: these should emit
Playlist A view of queued tracks selected for playback, allow user selecting a specific track + track_info Disambiguation Analog to playlist but with extra tracks populated during search user can select playback, but not queued WIP branch hereUsage Examples: Changes: TODO:
|
Very well summarized @JarbasAI, I like your proposed ui layout. One option would be if a skill could notify the audioservice that it's doing the playback and that the audioservice should query it for playlist and status instead of the audioservice, basically an audioservice->skill interface, this could be implemented as a separate service so the audioservice itself doesn't need to do anything special to handle the communication. Also to note initially the playback skill ui was meant as a simple fallback if the skill didn't implement the media playback ui by itself. Now it's growing to a complete multimedia thing so the more advanced ui should definitely be based on @AIIX's ui. |
Voight Kampff Integration Test Failed (Results) |
this is the example list entry i used for playlist model:
|
Have pushed the new UI to playback skill MycroftAI/skill-playback-control#31, it isn't wired up so will need to manually edit the skill to use the new player UI for now. It also consist of the mock test models in both the qml files and can be referenced to check how data is expected and assumptions. |
Voight Kampff Integration Test Failed (Results) |
mycroft/audio/services/__init__.py
Outdated
index = idx | ||
break | ||
elif index is None: | ||
index = len(self.track_data) - 1 |
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.
Can we trust the length of self.track_data
here?
I assume a dict is used because it may receive data on any track without the preceding track data necessarily existing?
So imagining:
- it receives only data about tracks with index's of 1 and 2
- then for some reason receives an index of None
- Would it therefore overwrite the track_data at index 1?
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.
I've cut this part of the PR since this was part of @JarbasAI WIP updates to the track handling in the audioservices.
This PR is now only the proposed standard methods for the the common play skills. Jarbas is/was working on a follow-up PR with those things.
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.
I haven't had much time, but im still working on this. I think its better if thats a follow up PR 👍
This adds the function used by the npr-news-skill and spotify-skill to communicate their info to the playback control showing the default playback UI. The function has the common parameters specified but is setup to be able to add new functionallity without core changes.
8bc56d7
to
116b2e5
Compare
Voight Kampff Integration Test Succeeded (Results) |
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.
Sorry it's taken me a while to get back to this. Looks like a great step forward to standardising this with the flexibility to add extra parameters as we flesh it out further.
All seems to be working well, and good documentation. Just a tiny nitpick I noticed.
mycroft/skills/common_play_skill.py
Outdated
image (str): url for image to show | ||
""" | ||
data = {'skill': self.name, | ||
"uri": uri, |
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.
nitpick - double quotes
116b2e5
to
7142664
Compare
Voight Kampff Integration Test Succeeded (Results) |
7142664
to
d7116b9
Compare
Voight Kampff Integration Test Failed (Results) |
Ah looks like we're missing |
This commit adds the status, extended track info as well as a tracklist information as proposed by Jarbasal.
Doh! And yes very good to have test suites picking these errors up :) Fixing |
d7116b9
to
8f4847f
Compare
Voight Kampff Integration Test Succeeded (Results) |
Provides track data for playlist | ||
|
||
Arguments: | ||
tracklist (str/list): Tracklist data |
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.
this should be dict or list of dicts, not str/list
uri (str): uri for track | ||
track_length (float): track length in seconds | ||
elapsed_time (float): current offset into track in seconds | ||
playlist_postion (int): |
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.
typo, position not postion, also missing an explanation of this argument
@dschweppe screenshots for the horizontal media player |
Description
This adds the method used by the npr-news-skill, spotify-skill to communicate their info to the playback control showing the default playback UI.
The method has the common parameters specified but is setup to be able to add new functionallity without core changes.
Points of discussion:
Status that could be of interest is
playing
,paused
andstopped
and maybeexited
so a boolprobably not fine grained enough I'd personally would probably prefer an enum for this.
How to test
Remove the matching methods from the npr-news skill and check that messages are still sent when playback starts.
Contributor license agreement signed?
CLA [ Yes ]