PangomNet / PanPlay

oOPlay Webplayer
https://play.pangom.net
MIT License
0 stars 1 forks source link

Laut.fm - Stacked Metatdata API-Calling #8

Closed PangomNet closed 1 month ago

PangomNet commented 6 months ago

Instead of loading all the information from the laut API individually, as is currently the case, it can be read out once in a stack and then distributed to the respective positions.

Thanks Paeddy for mentioning this. The laut extension will certainly receive a corresponding overhaul one day.

<script type="text/javascript" src="//api.laut.fm/js_tools/lautfm_js_tools.0.10.0.js.min.js" ></script>
<div id="api_lfm_radiode_link">Loading...</div>
<div id="api_lfm_phonostar_link">Loading...</div>
<div id="api_lfm_description">Loading...</div>
<div id="api_lfm_current_playlists">Loading...</div>

<script type="text/javascript" charset="utf-8">
var data = function(stationData){
   document.getElementById('api_lfm_radiode_link').innerHTML = 'Radio.de: ' + stationData.third_parties.radiode.url;
   document.getElementById('api_lfm_phonostar_link').innerHTML = 'Phonostar: ' + stationData.third_parties.phonostar.url;
   document.getElementById('api_lfm_description').innerHTML = 'Beschreibung: ' + stationData.description;
   document.getElementById('api_lfm_current_playlists').innerHTML = 'Aktuelle Sendung: ' + stationData.current_playlist.started_at.humanTimeShort() +' - ' + stationData.current_playlist.ends_at.humanTimeShort() + ' Uhr <br />Du H&ouml;rst: ' + stationData.current_playlist.name;
};
laut.fm.station('eins').info(data);
</script>
</script>
PangomNet commented 1 month ago

With the old method, everything was queried and loaded again, even if only one value had changed. With versions 0.0.1.9 (oOPlay Iris), 0.0.1.10 (oOPlay Acanthus - never released but modified and extended to Barberry), and finally 0.0.2.0 (PanPlay Barberry), the new API interface was integrated. The player requests the metadata once at the start and for changing dynamic content as soon as it changes. This approach was adopted from the behavior of the laut.fm JS API, on which the Laut.fm extension of the player is based. This change means that a single Java script function handles all communication with the API. As a result, queries can be consolidated as far as the API allows. In addition, the script logic is written in such a way that content is only queried or reloaded if the Laut.fm API “ considers this to be necessary”, for example because the content has been updated on the server in the meantime. Laut.fm therefore controls how often certain content needs to be re-requested. This reduces the network traffic to the Laut.fm standard, as the requests sent by the player are now halved.

With the last patch A from Barberry, the last queries were switched from the old method to the new one and all code segments of the old query were removed or taken from the active code by bracketing them out. This means that the old method can no longer be addressed.