Get metadata to display using .medialelement player for live streaming

I use the mediaelement audio shortcode for our shoutcast radio station site, because I didn’t want to use a plugin or external javascript. I want to get the metadata from our live or auto-dj radio on our page. I’m currently using an iframe, which works fine when station is on auto-dj. But when a dj is live, the metadata does not display.

I copied code from our old website (NOT a WordPress site), and changed the player names from jplayer to mediaelement player, but something isn’t right. Any help appreciated.

function lcsstream() {
this.streamInfo = {
url: ‘https://albireo.shoutca.st/rpc/lowercas/streaminfo.get‘,
data: {}
},
this.currently_playing = null,

this.init = function() {
var self = this;
$(“player”).mediaelementplayer({
ready: function (event) {
$(this).mediaelementplayer(“setMedia”, {
mp3:”http://142.4.217.133:8701/;”
}).mediaelementplayer(“play”);
},
supplied: “mp3”,
wmode: “window”
});

$.get(self.streamInfo.url, function (response) {
if (typeof response.data === “object”) {
self.streamInfo.data = response.data[0];
self.showCurrentlyPlaying();
console.log(self.streamInfo);
}
});
}

this.isLive = function() {
var self = this;
if (typeof self.streamInfo.data.offline === “boolean”) {
return !self.streamInfo.data.offline;
} else {
return false;
}
}

this.showCurrentlyPlaying = function() {
var self = this;
if (typeof self.streamInfo.data.song !== “undefined”) {
$(“#live-status”).removeClass(‘hidden’);
$(“#currently-playing”).text(self.streamInfo.data.song);
} else {
window.setTimeout(this.showCurrentlyPlaying, 500);
}
}

}

Read more here:: Get metadata to display using .medialelement player for live streaming

Leave a Reply

Your email address will not be published. Required fields are marked *