Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Mar 2021
    Posts
    13

    How to provide metadata through plugin the correct way?

    Hi,

    i am currently developing a plugin for streaming audio files from the ARD Audiothek. The problem i am facing now, is that can't find a nice way to display metadata in the player. My first try was to add a pseudo protocol handler, which worked for single files but not for playlists. Now i created a protocol handler which inherits from Slim::Player::Protocols::HTTPS und replaces my custom protocol "ardaudiothek://episode/{id}" with the correct streaming url, which is fetched from the ARD Audiothek api. The reason i created the "ardaudiothek://..." protocol is that i wanted favorites to be independent from the streaming url because this can change from time to time (files are cached in Akamai servers).

    So now when i select play on an episode its displayed in the player(i refer here to the one in LMS web page) with the metadata from getMetadataFor of my protocol handler, but a few seconds later it switches to metadata provided by the streamed mp3 file. This behaviour is probably related to the fact that i just replace my protocol with the streaming url which is of format "https://akamai..." and it then will be streamed by the HTTPS Protocol handler.

    Is there a way to prevent the metadata in the player to be replaced by the wma from the mp3 file or to tell the player to just use the provided data from my protocol handler and then stream with the HTTPS one?
    Btw: I don't want to use the mp3 metadata because in a lot of cases it is missing entries or provides wrong information. Metadata from the API is just better and complete.

    This is the link to current branch of the plugin repo:
    https://github.com/mzedd/LMS-ARD-Aud...rotocolhandler

    Thanks for your help

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,536

    How to provide metadata through plugin the correctway?

    > Now i created a protocol handler which inherits from
    > Slim::Player::Protocols::HTTPS und replaces my custom protocol
    > "ardaudiothek://episode/{id}" with the correct streaming url, which is
    > fetched from the ARD Audiothek api. The reason i created the
    > "ardaudiothek://..." protocol is that i wanted favorites to be
    > independent from the streaming url because this can change from time to
    > time (files are cached in Akamai servers).


    Way to go!

    > So now when i select play on an episode its displayed in the player(i
    > refer here to the one in LMS web page) with the metadata from
    > getMetadataFor of my protocol handler, but a few seconds later it
    > switches to metadata provided by the streamed mp3 file.


    Hmm... I'm not sure I've ever implemented a protocol handler for streams
    which would provide their own metadata. I believe you should overwrite
    the parseDirectHeaders() method in the protocol handler, and make sure
    you do NOT return a title (see eg. the WiMP protocol handler (aka.
    TIDAL)). This method is sent a series of headers which you then parse to
    extract eg. bitrate etc.

    Not sure whether this actually helps as I don't know where the stream
    would send the metadata. Maybe the player.streaming.* logging might help
    to tell you where it's reading them (header or stream).


  3. #3
    Junior Member
    Join Date
    Mar 2021
    Posts
    13
    Quote Originally Posted by mherger View Post
    Hmm... I'm not sure I've ever implemented a protocol handler for streams
    which would provide their own metadata. I believe you should overwrite
    the parseDirectHeaders() method in the protocol handler, and make sure
    you do NOT return a title (see eg. the WiMP protocol handler (aka.
    TIDAL)). This method is sent a series of headers which you then parse to
    extract eg. bitrate etc.
    I tried this, but parseDirectHeaders was never called. But thank you for the suggestion

    So I dug a little further into the code, especially of the scanUrl method and tried to hijack it's callback, but that was also unsuccessful.
    I searched again in the developer sub forum (probably for the fourth or fifth time today ) and found this old post from you. So the solution is just to overwrite the metadata from the mp3 again by the metadata i get from the ARD Audiothek. Not the prettiest way i think, but it works for now.

    So thanks for your help! Now i need to do a lot of refactoring, cleaning and decoupling of the code, but v1.0 shouldn't be far away

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,536

    How to provide metadata through plugin the correctway?

    > I searched again in the developer sub forum (probably for the fourth or
    > fifth time today ) and found this old 'post'
    > (
    > from you.


    Oh my... Good thing search did work. I actually wonder what plugin of
    mine I was referring to, as I thought I never had to deal with this
    situation before...

  5. #5
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,134
    I also used that as the basis for mine.

    I had to add a timer as well because this technique only works where the source is providing changing metadata in the stream.
    If they provide nothing (or only on first connect) then you need an additional way to get called.
    So I have a timer fire every 30 seconds or so and then use that to go and search for track data by kicking of a http fetch to somewhere - usually the same place that their own web interface gets the data from.
    The return from that fetch then calls the data parser which then changes the metadata and pushes it to the player ... if the data is not the same as last time.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •