From 3c7c0ae46c6b5e039dc7a4f1c9b247eff6dc0ff2 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 11 Jan 2014 14:24:32 +0100 Subject: [PATCH] docs: Use Extension.setup() in extensiondev guide --- docs/extensiondev.rst | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/extensiondev.rst b/docs/extensiondev.rst index dcd1681a..8c2cd16c 100644 --- a/docs/extensiondev.rst +++ b/docs/extensiondev.rst @@ -290,28 +290,29 @@ This is ``mopidy_soundspot/__init__.py``:: schema['password'] = config.Secret() return schema + def get_command(self): + from .commands import SoundspotCommand + return SoundspotCommand() + def validate_environment(self): try: import pysoundspot except ImportError as e: raise exceptions.ExtensionError('pysoundspot library not found', e) - # You will typically only implement one of the next three methods - # in a single extension. + def setup(self, registry): + # You will typically only do one of the following things in a + # single extension. - def get_frontend_classes(self): + # Register a frontend from .frontend import SoundspotFrontend - return [SoundspotFrontend] + registry.add('frontend', SoundspotFrontend) - def get_backend_classes(self): + # Register a backend from .backend import SoundspotBackend - return [SoundspotBackend] + registry.add('backend', SoundspotBackend) - def get_command(self): - from .commands import SoundspotCommand - return SoundspotCommand() - - def register_gstreamer_elements(self): + # Register a custom GStreamer element from .mixer import SoundspotMixer gobject.type_register(SoundspotMixer) gst.element_register( @@ -415,8 +416,8 @@ If you want to extend Mopidy's GStreamer pipeline with new custom GStreamer elements, you'll need to register them in GStreamer before they can be used. Basically, you just implement your GStreamer element in Python and then make -your :meth:`~mopidy.ext.Extension.register_gstreamer_elements` method register -all your custom GStreamer elements. +your :meth:`~mopidy.ext.Extension.setup` method register all your custom +GStreamer elements. For examples of custom GStreamer elements implemented in Python, see :mod:`mopidy.audio.mixers`.