From 88788fddfd7faff94e5a2b4ba2b3bbbb5aed3acf Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Sun, 3 Aug 2014 18:39:10 +0200 Subject: [PATCH] audio: Use pbutils to provide usable plugin missing info --- mopidy/audio/actor.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index 879a46c8..1d86b917 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -7,6 +7,7 @@ import gobject import pygst pygst.require('0.10') import gst # noqa +import gst.pbutils import pykka @@ -341,6 +342,8 @@ class Audio(pykka.ThreadingActor): elif msg.type == gst.MESSAGE_ELEMENT: if msg.structure.has_name('playbin2-stream-changed'): self._on_stream_changed(msg.structure['uri']) + elif gst.pbutils.is_missing_plugin_message(msg): + self._on_missing_plugin(msg) def _on_playbin_state_changed(self, old_state, new_state, pending_state): if new_state == gst.STATE_READY and pending_state == gst.STATE_NULL: @@ -401,6 +404,17 @@ class Audio(pykka.ThreadingActor): logger.debug('Triggering event: stream_changed(uri=%s)', uri) AudioListener.send('stream_changed', uri=uri) + def _on_missing_plugin(self, msg): + desc = gst.pbutils.missing_plugin_message_get_description(msg) + debug = gst.pbutils.missing_plugin_message_get_installer_detail(msg) + logger.warning('Could not find a %s to handle media.', desc) + if gst.pbutils.install_plugins_supported(): + logger.info('You might be able to fix this by running: ' + 'gst-installer "%s"', debug) + # TODO: store the missing plugins installer info in a file so we can + # can provide a 'mopidy install-missing-plugins' if the system has the + # required helper installed? + def set_uri(self, uri): """ Set URI of audio to be played.