diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index ca023125..5d12954c 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -102,6 +102,7 @@ class Audio(pykka.ThreadingActor): self._connect(playbin, 'about-to-finish', self._on_about_to_finish) self._connect(playbin, 'notify::source', self._on_new_source) + self._connect(playbin, 'source-setup', self._on_source_setup) self._playbin = playbin @@ -133,6 +134,22 @@ class Audio(pykka.ThreadingActor): self._appsrc = source + def _on_source_setup(self, element, source): + uri = element.get_property('uri') + if not uri or not uri.startswith('http://'): + return + + if self._config['proxy']['hostname']: + full_proxy = self._config['proxy']['hostname'] + if self._config['proxy']['port']: + full_proxy += ':' + str(self._config['proxy']['port']) + if self._config['proxy']['scheme']: + full_proxy = self._config['proxy']['scheme'] + "://" + full_proxy + + source.set_property('proxy', full_proxy) + source.set_property('proxy-id', self._config['proxy']['username']) + source.set_property('proxy-pw', self._config['proxy']['password']) + def _appsrc_on_need_data(self, appsrc, gst_length_hint): length_hint = utils.clocktime_to_millisecond(gst_length_hint) if self._appsrc_need_data_callback is not None: @@ -153,6 +170,7 @@ class Audio(pykka.ThreadingActor): def _teardown_playbin(self): self._disconnect(self._playbin, 'about-to-finish') self._disconnect(self._playbin, 'notify::source') + self._disconnect(self._playbin, 'source-setup') self._playbin.set_state(gst.STATE_NULL) def _setup_output(self):