I'm using this 'Now playing' jQuery plugin and was wondering if there's a way to split track info fetched from SHOUTcast (Artist name - Track title) into two different strings: 'Artist name' and 'Track title' separately.
This is the basic configuration of the plugin:
$.SHOUTcast({
host : '91.109.241.252',
port : 8170,
interval : 5000,
stats : function(){
$('#songtitle').text(this.get('songtitle','Temporarily Off Air'));
}
}).startStats();
The code above will return, every 5 seconds, the name in the format Artist name - Track title.
Is there a way to adapt the current configuration in order to achieve the same with the string splitted?
You can get the string "artist - song" and make a split:
var fullTitle = this.get('songtitle','Off Air').split(" - ");
Then get each item separately:
var artist = fullTitle[0];
var title = fullTitle[1];
And write it in different html tags:
$('#title').text(title);
$('#artist').text(artist);