I am now looking at adding a protocol handler for one of my plugins - so that I can have something like
radiogroup://station%20name
to play one
I have been reading
https://wiki.slimdevices.com/index.p...tocol_Handlers
and looked at some code in other plugins.
I can see that I need to call Slim::Player::ProtocolHandlers->registerHandler with the protocol name (radiogroup in this fake example) and the Perl package name as parameters.
Some have done this by having a file
ProtocolHandler.pm and then having something like this in the code of that module
Slim::Player::ProtocolHandlers->registerHandler('radiogroup', __PACKAGE__);
I am trying something similar but not seeing my code get called.
So ... does LMS automatically look for
ProtocolHandler.pm
to load in on plugin startup or is there something else that I have to do to get my ProtocolHandler.pm to be invoked?
Results 1 to 10 of 10
Thread: Adding a new protocol handler
-
2021-05-17, 04:04 #1
- Join Date
- Apr 2005
- Location
- UK/London
- Posts
- 5,494
Adding a new protocol handler
Paul Webster
Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin
-
2021-05-17, 04:20 #2
Adding a new protocol handler
> Some have done this by having a file
> ProtocolHandler.pm and then having something like this in the code of
> that module
> Slim::Player::ProtocolHandlers->registerHandler('radiogroup',
> __PACKAGE__);
>
> I am trying something similar but not seeing my code get called.
>
> So ... does LMS automatically look for
> ProtocolHandler.pm
> to load in on plugin startup or is there something else that I have to
> do to get my ProtocolHandler.pm to be invoked?
No, you'll have to do it in your Plugin.pm. I'd register there, and LMS
will then load the protocol handler if needed.
-
2021-05-17, 05:09 #3
- Join Date
- Oct 2005
- Location
- Ireland
- Posts
- 21,542
Some of this is a case of doing what other plugins have done.
Depending on functionality & how it is used, you may need to add an importer either by addImporter or in install.xml file.
-
2021-05-17, 06:24 #4
Adding a new protocol handler
> Some of this is a case of doing what other plugins have done.
> Depending on functionality & how it is used, you may need to add an
> importer either by addImporter or in install.xml file.
This is about the protocol handler, not the importer.
-
2021-05-17, 08:55 #5
- Join Date
- Apr 2005
- Location
- UK/London
- Posts
- 5,494
Thanks ... that made me look harder at other plugins.
They do their own call to get it loaded by putting a Use in Plugin.pm - like this
use Plugins::myPluginName::ProtocolHandler;
I'll experiment with this way as well.Paul Webster
Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin
-
2021-05-17, 09:06 #6
- Join Date
- Apr 2005
- Location
- UK/London
- Posts
- 5,494
As expected, that worked (calling it from Plugin.pm).
I quite like __PACKAGE__ as it makes it one less thing to remember when sharing code between plugins.
However, since I now have to remember to call the ProtocolHandler.pm from Plugin.pm then that is cancelled outPaul Webster
Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin
-
2021-11-21, 05:33 #7
- Join Date
- Jul 2010
- Location
- Oz
- Posts
- 406
-
2021-11-21, 07:07 #8
Adding a new protocol handler
>> No, you'll have to do it in your Plugin.pm. I'd register there, and LMS
>> will then load the protocol handler if needed.
>
> So you can register it in ProtocolHandler.pm and put -use
> Plugins::myPluginName::ProtocolHandler;- in Plugin.pm - or register it
> right there in Plugin.pm.
>
> Does it make a difference (ressources, etc.) or is the 'proper' way to
> do it more like a convention?
The difference is in the last part of my previous posting: by
registering it in Plugin.pm, the ProtocolHandler.pm would only be loaded
when needed. This probably doesn't make much difference for a plugin
which you'd only install to use that protocol, though.
-
2021-11-21, 11:16 #9
- Join Date
- Jul 2010
- Location
- Oz
- Posts
- 406
According to some comment in the LMS server code (Client.pm) it seems that modeParam was actually meant to replace param. I'll keep the (inherited :-) modeParam parts that work (Erland's plugins use it a lot, esp. with older devices like Boom or Transporter) and will use pluginData and Slim-Cache the way you've outlined.
Thank you very much for taking the time to explain all the details.
-
2021-11-22, 02:59 #10
Which cache to store non-persistent data for ashort time?
> It seems Michael answered this post here.
>
> https://forums.slimdevices.com/showt...=1#post1038722
Sorry about that. The forum <-> email list sometimes seems to mess with
thread IDs...