Skip to content
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

refactor:drop_audio_gui_player #132

Merged
merged 14 commits into from
Sep 17, 2024
19 changes: 4 additions & 15 deletions ovos_plugin_common_play/ocp/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from ovos_config import Configuration
from ovos_utils.events import EventSchedulerInterface
from ovos_utils.log import LOG
from ovos_workshop.backwards_compat import MediaType, Playlist, MediaEntry, PlayerState, LoopState, PlaybackType, PluginStream, dict2entry
from ovos_workshop.backwards_compat import (MediaType, Playlist, MediaEntry, PlayerState, LoopState,
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved
PlaybackType, PluginStream, dict2entry)

from ovos_plugin_common_play.ocp.constants import OCP_ID
from ovos_plugin_common_play.ocp.utils import is_qtav_available
Expand Down Expand Up @@ -64,10 +65,6 @@ def home_screen_page(self):
def disambiguation_playlists_page(self):
return "SuggestionsView"

@property
def audio_player_page(self):
return "OVOSAudioPlayer"

@property
def audio_service_page(self):
return "OVOSSyncPlayer"
Expand Down Expand Up @@ -314,19 +311,11 @@ def show_player(self):

# page helpers
def _get_player_page(self):
if self.player.active_backend == PlaybackType.AUDIO_SERVICE or \
self.player.settings.get("force_audioservice", False):
return self.audio_service_page
elif self.player.active_backend == PlaybackType.VIDEO:
if self.player.active_backend == PlaybackType.VIDEO:
return self.video_player_page
elif self.player.active_backend == PlaybackType.AUDIO:
return self.audio_player_page
elif self.player.active_backend == PlaybackType.WEBVIEW:
return self.web_player_page
elif self.player.active_backend == PlaybackType.MPRIS:
return self.audio_service_page
else: # external playback (eg. skill)
# TODO ?
else:
return self.audio_service_page

def _get_pages_to_display(self):
Expand Down
19 changes: 1 addition & 18 deletions ovos_plugin_common_play/ocp/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,31 +424,14 @@ def play(self):
self.track_history[self.now_playing.uri] += 1

LOG.debug(f"Requesting playback: {repr(self.active_backend)}")
if self.active_backend == PlaybackType.AUDIO and not is_gui_running():
# NOTE: this is already normalized in self.validate_stream, using messagebus
# if we get here the GUI probably crashed, or just isnt "mycroft-gui-app" or "ovos-shell"
# is_gui_running() can not be trusted, log a warning only
LOG.warning("Requested Audio playback via GUI, but GUI doesn't seem to be running?")

if self.active_backend == PlaybackType.AUDIO_SERVICE:
if self.active_backend in [PlaybackType.AUDIO_SERVICE, PlaybackType.AUDIO]:
LOG.debug("Handling playback via audio_service")
# we explicitly want to use an audio backend for audio only output
self.audio_service.play(self.now_playing.uri,
utterance=self.audio_service_player)
self.bus.emit(Message("ovos.common_play.track.state", {
"state": TrackState.PLAYING_AUDIOSERVICE}))
self.set_player_state(PlayerState.PLAYING)
elif self.active_backend == PlaybackType.AUDIO:
LOG.debug("Handling playback via gui")
# handle audio natively in mycroft-gui
sleep(2) # wait for gui page to start or this is sent before page
self.bus.emit(Message("gui.player.media.service.play", {
"track": self.now_playing.uri,
"mime": self.now_playing.mimetype,
"repeat": False}))
sleep(0.2) # wait for the above message to be processed
self.bus.emit(Message("ovos.common_play.track.state", {
"state": TrackState.PLAYING_AUDIO}))
elif self.active_backend == PlaybackType.SKILL:
LOG.debug("Requesting playback: PlaybackType.SKILL")
if self.now_playing.is_cps: # mycroft-core compat layer
Expand Down
Loading
Loading