Skip to content

Commit

Permalink
fix/ocp_api_context
Browse files Browse the repository at this point in the history
pass kwarg for source message, in some cases dig_for_message returns None  (unsure when it happens, but issues noticed with hivemind)

companion to OpenVoiceOS/ovos-bus-client#103
  • Loading branch information
JarbasAl committed Jul 12, 2024
1 parent 8124f0d commit 8ac983a
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions ovos_core/intent_services/ocp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ def handle_play_intent(self, message: Message):
# ovos-PHAL-plugin-mk1 will display music icon in response to play message
player = self.get_player(message)
if not player.ocp_available:
self.legacy_play(results, query)
self.legacy_play(results, query, message=message)
else:
self.ocp_api.play(results, query)
self.ocp_api.play(results, query, source_message=message)

def handle_open_intent(self, message: Message):
LOG.info("Requesting OCP homescreen")
Expand All @@ -606,10 +606,10 @@ def handle_stop_intent(self, message: Message):
player = self.get_player(message)
if not player.ocp_available:
LOG.info("Requesting Legacy AudioService to stop")
self.legacy_api.stop()
self.legacy_api.stop(source_message=message)
else:
LOG.info("Requesting OCP to stop")
self.ocp_api.stop()
self.ocp_api.stop(source_message=message)
player = self.get_player(message)
player.player_state = PlayerState.STOPPED
self.update_player_proxy(player)
Expand All @@ -618,28 +618,28 @@ def handle_next_intent(self, message: Message):
player = self.get_player(message)
if not player.ocp_available:
LOG.info("Requesting Legacy AudioService to go to next track")
self.legacy_api.next()
self.legacy_api.next(source_message=message)
else:
LOG.info("Requesting OCP to go to next track")
self.ocp_api.next()
self.ocp_api.next(source_message=message)

def handle_prev_intent(self, message: Message):
player = self.get_player(message)
if not player.ocp_available:
LOG.info("Requesting Legacy AudioService to go to prev track")
self.legacy_api.prev()
self.legacy_api.prev(source_message=message)
else:
LOG.info("Requesting OCP to go to prev track")
self.ocp_api.prev()
self.ocp_api.prev(source_message=message)

def handle_pause_intent(self, message: Message):
player = self.get_player(message)
if not player.ocp_available:
LOG.info("Requesting Legacy AudioService to pause")
self.legacy_api.pause()
self.legacy_api.pause(source_message=message)
else:
LOG.info("Requesting OCP to go to pause")
self.ocp_api.pause()
self.ocp_api.pause(source_message=message)
player = self.get_player(message)
player.player_state = PlayerState.PAUSED
self.update_player_proxy(player)
Expand All @@ -648,10 +648,10 @@ def handle_resume_intent(self, message: Message):
player = self.get_player(message)
if not player.ocp_available:
LOG.info("Requesting Legacy AudioService to resume")
self.legacy_api.resume()
self.legacy_api.resume(source_message=message)
else:
LOG.info("Requesting OCP to go to resume")
self.ocp_api.resume()
self.ocp_api.resume(source_message=message)
player = self.get_player(message)
player.player_state = PlayerState.PLAYING
self.update_player_proxy(player)
Expand All @@ -662,10 +662,10 @@ def handle_search_error_intent(self, message: Message):
player = self.get_player(message)
if not player.ocp_available:
LOG.info("Requesting Legacy AudioService to stop")
self.legacy_api.stop()
self.legacy_api.stop(source_message=message)
else:
LOG.info("Requesting OCP to stop")
self.ocp_api.stop()
self.ocp_api.stop(source_message=message)

# NLP
def voc_match_media(self, query: str, lang: str) -> Tuple[MediaType, float]:
Expand Down Expand Up @@ -1026,7 +1026,7 @@ def legacy_play(self, results: List[Union[MediaEntry, Playlist, PluginStream]],
# for legacy audio service we need to do stream extraction here
res.append(r.extract_uri(video=False))

self.legacy_api.play(res, utterance=phrase)
self.legacy_api.play(res, utterance=phrase, source_message=message)

player = self.get_player(message)
player.player_state = PlayerState.PLAYING
Expand Down

0 comments on commit 8ac983a

Please sign in to comment.