Is there a way to show current "show logo"

Hi All,

I’m currently setting up a pair of Libretime servers for a London based Radio station.

Both hosted on Ubuntu 18.04 and so far, working great!

Firstly, just wanted to say was an incredible tool LibreTime is! Well done to everyone involved, it’s very impressive.

My question:

Another Developer is working on a Wordpress site to act as the station’s homepage, which will be hosted on a different box running who-knows-what v2.0. Likely a shared hosting platform.

Is there a way to get the currently playing show name and logo from the LibreTime server so it can be displayed dynamically on the Wordpress homepage?

Many thanks in advance!

Dx

You can tell him to use the API for live info. http://your-site/api/live-info

That will give you the start timestamp, end timestamp, name of show, description, image set for the current show. Also for the next or previous show, and current playing track with all it’s info.

If you want to get info for the shows on the week, you can use http://your-site/api/week-info

Many thanks for your help!

Works like an absolute charm :grinning:

In case anyone stumbles across this looking to do the same thing:

To get the current show image to display (wherever you want) you can use something like the below:

<img src="<?php
//Collect currently playing info from server API
$obj = json_decode(file_get_contents('http://YOUR_SERVER.com/api/live-info'), true);

//echo currently playing image
echo $obj['currentShow'][0]['image_path'];?>" />

I’m glad you got it working. You might also want to add an ID to that image element and use some jQuery to check if the show has changed, that way you don’t need to refresh the page. Example:

function liveInfoJson() {
   jQuery(function() {
        jQuery.getJSON(
        "https://your-site/api/live-info",
        function(json){
            var api_curr_show_artwork = json.currentShow[0].image_path;
            var site_curr_show_artwork = jQuery("#current-show-img").attr("src");
            if (api_curr_show_artwork != site_curr_show_artwork) {
                jQuery("#current-show-img").attr("src", api_curr_show_artwork);
            }
        });
   });
}

jQuery(document).ready(function($) {
    window.setInterval(function(){
      liveInfoJson();
    }, 5000);
});

Many thanks again!

A great idea, I know very little javascript, hence trying to solve it in php.

Running your code (Jquery included from googleapis) I get the following error:

[Error] XMLHttpRequest cannot load http://libretimeserver/api/live-info due to access control checks.
[Error] Failed to load resource: Origin http://websiteserver is not allowed by Access-Control-Allow-Origin. (live-info, line 0)

Which, I guess is same-origin protection. Given that I’m forced to fun this across domains, is there a secure workaround? short of doing a Access-Control-Allow-Origin: *?

EDIT:

Found it! in the LibreTime settings you can allow with: Allowed CORS URLs

Thanks again!

1 Like

Are any of these WordPress sites live? Please feel free to mention in the Sites using LibreTime thread.

Also would be great to have some more input from WordPress developers on Planning out an API