(function($){
"use strict";
function isXML(xml){
try {
xmlDoc=$.parseXML(xml);
return true;
} catch (err){
return false;
}}
$.qtmplayerRadioFeedObj={
body: $("body"),
window: $(window),
document: $(document),
htmlAndbody: $('html,body'),
qtFeedData: {},
timeInterval: 15000,
fn: {
cachedThumbsArray: [],
updateMediaData(){
if('mediaSession' in navigator){
if($.qtMplayerGlobalSongData.thumbnail&&false!==$.qtMplayerGlobalSongData.thumbnail){
navigator.mediaSession.metadata=new MediaMetadata({
title: $.qtMplayerGlobalSongData.title,
artist: $.qtMplayerGlobalSongData.artist,
artwork: [
{ src: $.qtMplayerGlobalSongData.thumbnail,  type: "image/jpeg" }
]
});
}else{
navigator.mediaSession.metadata=new MediaMetadata({
title: $.qtMplayerGlobalSongData.title,
artist: $.qtMplayerGlobalSongData.artist
});
}}
},
getThumbnailOriginal: function(that, termArray, callBack){
var preclean=termArray.split('<!--');
if(preclean.length > 1){
termArray=preclean[0];
}
termArray=termArray.split(' - ').join('-').split(' ').join('+');
var thumb;
var apiUrl;
apiUrl =
'https://itunes.apple.com/search'
+ '?media=music'
+ '&entity=album'
+ '&attribute=albumTerm'
+ '&limit=25'
+ '&term=' + encodeURIComponent(termArray);
apiUrl='https://itunes.apple.com/search?limit=4&media=music&term='+termArray;
if(termArray=='Song title unavailable'||termArray=='No Titles Available'){
thumb=$.qtmplayerRadioFeedObj.qtFeedData.cover;
that.cachedThumbsArray[termArray]=thumb;
$.qtMplayerGlobalSongData.thumbnail=thumb;
callBack(thumb);
return;
}
if(undefined===that.cachedThumbsArray[termArray]){
if($.qtmplayerRadioFeedObj.qtFeedData.artwork){
termArray=termArray.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, '');
callBack($.qtmplayerRadioFeedObj.qtFeedData.artwork+'?song='+termArray);
}else{
$.ajax({
type: 'GET',
cache: true,
url: apiUrl,
async: true,
dataType: 'jsonp',
context: this,
success: function(json){
if('object'!==typeof(json)){
json=JSON.parse(json);
}
if(json.resultCount > 0){
thumb=json.results[0].artworkUrl100.split('100x100bb.jpg').join('1000x1000bb.jpg');
that.cachedThumbsArray[termArray]=thumb;
$.qtMplayerGlobalSongData.thumbnail=thumb;
callBack(thumb);
return;
}}
});
}}else{
$.qtMplayerGlobalSongData.thumbnail=that.cachedThumbsArray[termArray];
callBack(that.cachedThumbsArray[termArray]);
return;
}
$.qtmplayerRadioFeedObj.fn.updateMediaData();
},
getThumbnail: function(that, termArray, callBack){
var preclean=termArray.split('<!--');
if(preclean.length > 1){ termArray=preclean[0]; }
var cacheKey=termArray.split(' - ').join('-').split(' ').join('+');
if(termArray==='Song title unavailable'||termArray==='No Titles Available'){
var ph=$.qtmplayerRadioFeedObj.qtFeedData.cover||false;
that.cachedThumbsArray[cacheKey]=ph;
if(ph){ $.qtMplayerGlobalSongData.thumbnail=ph; }
callBack(ph);
return;
}
if(that.cachedThumbsArray[cacheKey]!==undefined){
var c=that.cachedThumbsArray[cacheKey];
if(c){ $.qtMplayerGlobalSongData.thumbnail=c; }
callBack(c||false);
return;
}
if($.qtmplayerRadioFeedObj.qtFeedData.artwork){
var slug=termArray.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, '');
var staticUrl=$.qtmplayerRadioFeedObj.qtFeedData.artwork + '?song=' + encodeURIComponent(slug);
that.cachedThumbsArray[cacheKey]=staticUrl;
$.qtMplayerGlobalSongData.thumbnail=staticUrl;
callBack(staticUrl);
return;
}
var ua=navigator.userAgent||navigator.vendor||window.opera;
var isiOS=/iPad|iPhone|iPod/.test(ua)&&!window.MSStream;
var q=encodeURIComponent(
termArray.toLowerCase().trim().replace(/\s*-\s*/g,'-').replace(/\s+/g,' ')
);
var apiUrl=isiOS
? ('https://itunes.apple.com/search?limit=20&entity=musicTrack&term=' + q) // no media=music on iOS
: ('https://itunes.apple.com/search?limit=4&media=music&term=' + q);
var isMusicResult=function(r){
if(!r) return false;
var badKinds=['feature-movie','ebook','podcast','tv-episode','software'];
if(badKinds.indexOf(r.kind)!==-1) return false;
if(r.kind==='song') return true;
if(r.wrapperType==='collection'&&(r.collectionType==='Album'||r.collectionType==='Compilation')) return true;
return false;
};
var pickArt=function(list){
var picks=(list||[]).filter(isMusicResult).sort(function(a,b){
var rank=function(r){
if(r.kind==='song') return 1;
if(r.wrapperType==='collection') return 2;
return 9;
};
return rank(a) - rank(b);
});
if(!picks.length) return null;
var r0=picks[0];
var art=(r0.artworkUrl100||r0.artworkUrl60||r0.artworkUrl30||'').toString();
return art ? art.replace('100x100bb.jpg','1000x1000bb.jpg'):null;
};
var done=function(url){
that.cachedThumbsArray[cacheKey]=url||false;
if(url){ $.qtMplayerGlobalSongData.thumbnail=url; }
callBack(url||false);
};
var handleSuccess=function(json, triedAlbumFallback){
if(typeof json!=='object'){ try{ json=JSON.parse(json); }catch(e){ json={results:[]};}}
var art=pickArt(json.results);
if(art){ done(art); return; }
if(isiOS&&!triedAlbumFallback){
$.ajax({
type: 'GET',
cache: true,
url: 'https://itunes.apple.com/search?limit=20&entity=album&term=' + q,
async: true,
dataType: 'jsonp',
success: function(json2){ handleSuccess(json2, true); },
error: function(){ done($.qtmplayerRadioFeedObj.qtFeedData.cover||false); }});
return;
}
done($.qtmplayerRadioFeedObj.qtFeedData.cover||false);
};
$.ajax({
type: 'GET',
cache: true,
url: apiUrl,
async: true,
dataType: 'jsonp',
success: function(json){ handleSuccess(json, false); },
error: function(){ done($.qtmplayerRadioFeedObj.qtFeedData.cover||false); }});
$.qtmplayerRadioFeedObj.fn.updateMediaData();
},
marqueeInstances: [],
marqueeText: function(that){
if('function'!==typeof($.fn.marquee) ){
return;
}
var marquees=$('body').find('.proradio-marquee');
if(that.marqueeInstances.length > 0){
for(var mi=0; mi < that.marqueeInstances.length; mi++){
if('undefined'!==typeof(that.marqueeInstances[mi])){
that.marqueeInstances[mi].marquee('destroy');
}}
that.marqueeInstances=[];
}
$.each(marquees, function(i,c){
var item=$(c);
if(item.find('.marquee').length===0){
item.html('<span class="marquee">'+item.html()+'</span>');
}
if(item.outerWidth() >  item.find('.marquee').outerWidth()){
return;
}
that.marqueeInstances[i]=item.marquee({
duration: 20000,
gap: 150,
delayBeforeStart: 0,
direction: 'left',
duplicated: true,
pauseOnCycle: 0,
startVisible: true
});
});
},
qtApplyListeners: function(listeners, listener_peak){
if($.qtmplayerRadioFeedObj.qtFeedData.listeners||$.qtmplayerRadioFeedObj.qtFeedData.listenerspeak){
if(listeners||listener_peak){
$(".qtmplayer__stats").addClass('show');
if(listeners&&$.qtmplayerRadioFeedObj.qtFeedData.listeners){
$('.qtmplayer-listeners span').html(listeners);
$('.qtmplayer-listeners').show();
}else{
$('.qtmplayer-listeners').hide();
}
if(listener_peak&&$.qtmplayerRadioFeedObj.qtFeedData.listenerspeak){
$('.qtmplayer-listener_peak span').html(listener_peak);
$('.qtmplayer-listener_peak').show();
}else{
$('.qtmplayer-listener_peak').hide();
}
return true;
}}
$(".qtmplayer__stats").removeClass('show');
$('.qtmplayer-listeners span').html('');
$('.qtmplayer-listener_peak span').html('');
return;
},
qtApplyTitle: function(result, callBack){
var that=this;
if(result&&result!==''){
var dmes='>>>>> qtApplyTitle:'+result;
$.qtmplayerRadioFeedObj.fn.log(dmes);
var feedsplit=result.split(" - ");
var artist;
var title;
if(feedsplit.length > 1){
artist=feedsplit[0],
title=feedsplit[1];
}else{
feedsplit=result.split("-");
if(feedsplit.length > 1){
artist=feedsplit[0],
title=feedsplit[1];
}else{
artist="";
title=result;
}}
var artistSplit=artist.split('[');
if(artistSplit.length > 1){
artist=artistSplit[0];
}
artistSplit=artist.split(':');
if(artistSplit.length > 1){
artist=artistSplit[1];
}
var titleSplit=title.split('[');
if(titleSplit.length > 1){
title=titleSplit[0];
}
title=$.trim(title);
artist=$.trim(artist);
$(".qtmplayer-feed").show();
var publicTitle=title;
var publicArtist=artist;
var fd=$.qtmplayerRadioFeedObj&&$.qtmplayerRadioFeedObj.qtFeedData;
if(fd&&String(fd.revt)==='1'){
publicTitle=artist;
publicArtist=title;
}
if(fd&&String(fd.nobreak)==='1'){
publicTitle=publicTitle+ ' - ' +publicArtist;
publicArtist='';
}
if(fd&&String(fd.radiotitle)==='1'&&fd.title){
publicTitle=fd.title+ ' | ' + publicTitle;
}
$('.qtmplayer__title').html(publicTitle);
$('.qtmplayer__artist').html(publicArtist);
that.marqueeText(that);
var termArray=artist+'-'+title;
if(callBack){
this.getThumbnail(that, termArray, callBack);
}
if(window.screen.width < 670){
var uA=navigator.userAgent||navigator.vendor||window.opera;
if(/Googlebot/i.test(uA)||/Bing/i.test(uA)||/Yandex/i.test(uA)||/Apple Bot/i.test(uA)||/DuckDuck Bot/i.test(uA)){
}else{
jQuery(document).prop('title',  artist+' - '+title);
}}
$.qtMplayerGlobalSongData.title=title;
$.qtMplayerGlobalSongData.artist=artist;
$.qtmplayerRadioFeedObj.fn.updateMediaData();
}else{
$(".qtmplayer-feed").hide();
}
return;
},
newFeedReading: function(){
$.qtmplayerRadioFeedObj.fn.log('newFeedReading=REITERATE - '+$.now());
var o=$.qtmplayerRadioFeedObj,
fd=o.qtFeedData,
callBack=fd.callBack,
fn=o.fn,
qtradiofeedHost=(undefined!==fd.host) ? fd.host:'',
qtradiofeedPort=(undefined!==fd.port) ? fd.port:'',
qtradiofeedProtocol=(undefined!==fd.protocol) ? fd.protocol:'http',
theChannel=(undefined!==fd.channel) ? fd.channel:'',
qticecasturl=(undefined!==fd.icecasturl) ? fd.icecasturl:'',
qticecastmountpoint=(undefined!==fd.icecastmountpoint) ? fd.icecastmountpoint:'',
qticecastchannel=(undefined!==fd.icecastchannel) ? fd.icecastchannel:'',
qtradiodotco=(undefined!==fd.radiodotco) ? fd.radiodotco:'',
qtairtime=(undefined!==fd.airtime) ? fd.airtime:'',
qtradionomy=(undefined!==fd.radionomy) ? fd.radionomy:'',
qttextfeed=(undefined!==fd.textfeed) ? fd.textfeed:'',
qtUseProxy=(undefined!==fd.useproxy) ? fd.useproxy:'',
qtlive365=(undefined!==fd.live365) ? fd.live365:'',
qtradioking=(undefined!==fd.radioking) ? fd.radioking:'',
qtazuracast=(undefined!==fd.azuracast) ? fd.azuracast:'',
qtsecuresystems=(undefined!==fd.securesystems) ? fd.securesystems:'',
qtradiojar=(undefined!==fd.radiojar) ? fd.radiojar:'',
qtradioboss=(undefined!==fd.radioboss) ? fd.radioboss:'',
qtmaxcast=(undefined!==fd.maxcast) ? fd.maxcast:'',
qtsonicpanel=(undefined!==fd.sonicpanel) ? fd.sonicpanel:'',
qtsonicpaneldj=(undefined!==fd.sonicpaneldj) ? fd.sonicpaneldj:'',
qtjazler=(undefined!==fd.jazler) ? fd.jazler:'',
qteverestcast=(undefined!==fd.everestcast) ? fd.everestcast:'',
qtstreamerr=(undefined!==fd.streamerr) ? fd.streamerr:'',
qtstreamguys_api=(undefined!==fd.streamguys_api) ? fd.streamguys_api:'',
qtstreamguys_uuid=(undefined!==fd.streamguys_uuid) ? fd.streamguys_uuid:'',
qtradiocult=(undefined!==fd.radiocult) ? fd.radiocult:'',
broadcastradio=(undefined!==fd.broadcastradio) ? fd.broadcastradio:'',
radiolize=(undefined!==fd.radiolize) ? fd.radiolize:'',
stationplaylist=(undefined!==fd.stationplaylist) ? fd.stationplaylist:'',
yesstreaming=(undefined!==fd.yesstreaming) ? fd.yesstreaming:'',
schedulefilter=(undefined!==fd.schedulefilter) ? fd.schedulefilter:'',
qtFeedPlayerTrack=$('#qtFeedPlayerTrack'),
qtFeedPlayerAuthor=$('#qtFeedPlayerAuthor'),
qtPlayerTrackInfo=$("#qtPlayerTrackInfo"),
author, title, result, feedsplit;
o=$.qtmplayerRadioFeedObj;
var proxyURL=$("#qtmplayer-radiofeed-proxyurl").data('proxyurl');
var timestamp=new Date().getUTCMilliseconds();
var listener_peak=false;
var listeners=false;
if(fd.servertype=='type-radioshow'){
var showUrl=proxyURL+'?proradio-currentshow=1';
if(schedulefilter){
showUrl=showUrl+'&filterquery='+schedulefilter;
}
$.ajax({
type: 'GET',
cache: false,
url: showUrl,
async: true,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
if(data.title){
if(data.subtitle2){
data.title=data.subtitle2+' - '+data.title;
}
fn.qtApplyTitle(data.title);
}
if(data.image){
var img=data.image;
if(data.title){
var slug=data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, '');
img +='?title=' + encodeURIComponent(slug);
}
$.qtMplayerGlobalSongData.thumbnail=img;
if(typeof callBack==='function'){
callBack(img);
}}
if(!data.image&&data.thumb){
$.qtMplayerGlobalSongData.thumbnail=data.thumb;
if(typeof callBack==='function') callBack(data.thumb);
}},
error: function(e){
console.log(e);
}});
}
if(fd.servertype=='type-yesstreaming'&&yesstreaming){
if(qtUseProxy){
yesstreaming=proxyURL+'?qtproxycall='+window.btoa(yesstreaming);
}
$.ajax({
type: 'GET',
cache: false,
url: yesstreaming,
async: true,
jsonp: "callback",
success: function(data){
if(typeof data!=='object'){
try {
data=JSON.parse(data);
} catch (e){
console.log("Invalid JSON from Radiolize");
return;
}}
var results=data.results[0];
var trackTitlte=data.results[0].metadata;
if('undefined'!==typeof(data.results[0].img_url)&&data.results[0].img_url&&'function'===typeof(callBack)){
console.log(data.results[0].img_url);
callBack(data.results[0].img_url);
callBack=false;
}
if(trackTitlte){
fn.qtApplyTitle(trackTitlte, callBack);
}else{
console.log(yesstreaming);
console.log('Yesstreaming title not available');
fn.qtApplyTitle('Title not available', callBack);
}},
error: function(e){
console.log(yesstreaming);
console.log('Yesstreaming feed not loaded - error ahead:');
console.log(e);
}});
return;
}
if(fd.servertype=='type-stationplaylist'&&stationplaylist){
if(qtUseProxy){
stationplaylist=proxyURL+'?qtproxycall='+window.btoa(stationplaylist);
}
$.ajax({
type: "GET",
url:stationplaylist,
dataType: "xml",
async: true,
cache: false,
success: function(xml){
fn.log(xml);
$(xml).find('Current').each(function(){
fn.log($(this));
var song=$(this);
var title=song.find('Title').html();
var artist=song.find('Artist').html();
var artwork=song.find('Image');
if(artwork){
artwork=artwork.html();
if(artwork!=''){
callBack(artwork);
callBack=false;
}}
fn.qtApplyTitle(title + ' - ' + artist , callBack);
});
},
error: function(e){
console.log('stationplaylist source unreachable - please check your channel settings');
console.log(e);
}});
return;
}
if(fd.servertype=='type-radiolize'&&radiolize){
if(qtUseProxy){
radiolize=proxyURL+'?qtproxycall='+window.btoa(radiolize);
}
$.ajax({
type: 'GET',
url: radiolize,
cache: false,
async: true,
dataType: 'json',
success: function(data){
if(typeof data!=='object'){
try {
data=JSON.parse(data);
} catch (e){
console.log("Invalid JSON from Radiolize");
return;
}}
if(!data.now_playing||!data.now_playing.song||!data.now_playing.song.text){
fn.log("Missing data for Radiolize song title");
return;
}
var title=data.now_playing.song.text;
if(typeof data.now_playing.song.art!=='undefined'&&data.now_playing.song.art&&typeof callBack==='function'){
var img=data.now_playing.song.art;
$.qtMplayerGlobalSongData.thumbnail=img;
callBack(img);
callBack=false;
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log('Broadcast.Radio feed not loaded - error ahead:');
console.log(e);
}});
return;
}
if(fd.servertype=='type-broadcastradio'&&broadcastradio){
if(qtUseProxy){
broadcastradio=proxyURL+'?qtproxycall='+window.btoa(broadcastradio);
}
$.ajax({
type: 'GET',
cache: false,
url: broadcastradio,
async: true,
jsonp: true,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
if(!data.success){
fn.log("Missing data for Broadcast.Radio song title");
return;
}
title=data.body.now_playing.title;
if(data.body.now_playing.artist){
title=title +' - ' + data.body.now_playing.artist;
}
if('undefined'!==typeof(data.body.now_playing.artworkUrl)&&data.body.now_playing.artworkUrl&&'function'===typeof(callBack)){
if('undefined'!==typeof(data.body.now_playing.artworkUrl) ){
if(data.body.now_playing.artworkUrl){
var img=data.body.now_playing.artworkUrl;
$.qtMplayerGlobalSongData.thumbnail=img;
callBack(img);
callBack=false;
}}
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log('Broadcast.Radio feed not loaded - error ahead:');
console.log(e);
}});
return;
}
if(fd.servertype=='type-radiocult'&&qtradiocult){
qtradiocult=proxyURL+'?qtproxycall='+window.btoa(qtradiocult);
$.ajax({
type: 'GET',
cache: false,
url: qtradiocult,
async: true,
jsonp: true,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
if(!data.result.metadata){
fn.log("Missing data for Radiocult song title");
return;
}
title=data.result.metadata.title;
if(data.result.metadata.artist){
title=title +' - ' + data.result.metadata.artist;
}
if('undefined'!==typeof(data.result.metadata.artwork)&&data.result.metadata.artwork&&'function'===typeof(callBack)){
if('undefined'!==typeof(data.result.metadata.artwork.original) ){
if(data.result.metadata.artwork.original){
var img=data.result.metadata.artwork.original;
$.qtMplayerGlobalSongData.thumbnail=img;
callBack(img);
callBack=false;
}}
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log('Streamguys feed not loaded - error ahead:');
console.log(e);
}});
return;
}
if(fd.servertype=='type-streamguys'&&qtstreamguys_api&&qtstreamguys_uuid){
var apiurl='https://jetapi.streamguys.com/'+qtstreamguys_api+'/scraper/'+qtstreamguys_uuid+'/metadata/raw/';
if(qtUseProxy){
apiurl=proxyURL+'?qtproxycall='+window.btoa(apiurl);
}
$.ajax({
type: 'GET',
cache: false,
url: apiurl,
async: true,
jsonp: true,
success: function(text){
if(text=='{"error":"API Key not found."}'){
return;
}
var match=text.match(/StreamTitle='(.*?)'/);
var title=match ? match[1]:"";
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log('Streamguys feed not loaded - error ahead:');
console.log(e);
}});
return;
}
if(fd.servertype=='type-everestcast'){
fn.log(qteverestcast);
if(qtUseProxy){
qteverestcast=proxyURL+'?qtproxycall='+window.btoa(qteverestcast);
}
$.ajax({
type: 'GET',
cache: false,
url: qteverestcast,
async: true,
jsonp: true,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
if(!data.current_track.title){
fn.log("Missing data for Everestcast song title");
return;
}
title=data.current_track.title;
if(data.current_track.image&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.current_track.image;
callBack(data.current_track.image);
callBack=false;
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log('MediaCP feed not loaded - error ahead:');
console.log(e);
}});
return;
}
if(fd.servertype=='type-mediacp'){
fn.log(qtmediacp);
if(qtUseProxy){
qtmediacp=proxyURL+'?qtproxycall='+window.btoa(qtmediacp);
}
$.ajax({
type: 'GET',
cache: false,
url: qtmediacp,
async: true,
jsonp: true,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
fn.log(data);
title=data.nowplaying;
if(data.coverart&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.coverart;
callBack(data.coverart);
callBack=false;
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log('MediaCP feed not loaded - error ahead:');
console.log(e);
}});
return;
}
if(fd.servertype=='type-streamerr'){
fn.log(qtstreamerr);
if(qtUseProxy){
qtstreamerr=proxyURL+'?qtproxycall='+window.btoa(qtstreamerr);
}
$.ajax({
type: 'GET',
cache: false,
url: qtstreamerr,
async: true,
jsonp: true,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
fn.log(data);
title=data.nowplaying;
if(data.coverart&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.coverart;
callBack(data.coverart);
callBack=false;
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log('Streamerr not working - error ahead:');
console.log(e);
}});
return;
}
if(fd.servertype=='type-sonicpanel'){
if(qtsonicpanel!==''){
if(qtsonicpanel.indexOf("?") > -1){
qtsonicpanel=qtsonicpanel + '&rand='+timestamp;
}else{
qtsonicpanel=qtsonicpanel + '?rand='+timestamp;
}
if(qtUseProxy){
qtsonicpanel=proxyURL+'?qtproxycall='+window.btoa(qtsonicpanel);
}
$.ajax({
type: 'GET',
cache: false,
url: qtsonicpanel,
async: true,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
var titles='Now live - Streaming';
if(data.title){
titles=data.title;
if(data.artist){
titles=data.artist+' - '+data.title;
}}
if(data.art&&'function'===typeof(callBack)){
if(data.title){
data.art=data.art + '?title=' + data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, '');
}
$.qtMplayerGlobalSongData.thumbnail=data.art;
callBack(data.art);
callBack=false;
}
if(data.thumb&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.thumb+'#.jpg';
callBack(data.thumb+'#.jpg');
callBack=false;
}
if('1'==qtsonicpaneldj&&data.djusername!=='No DJ'){
titles=data.title.split(' - ').join(' / ')+' - '+data.djusername;
}
if(data.listn){
listeners=data.listn;
}
if(data.peaklistn){
listener_peak=data.peaklistn;
}
fn.qtApplyListeners(listeners, listener_peak);
fn.qtApplyTitle(titles, callBack);
},
error: function(e){
console.log(e);
}});
}}
if(fd.servertype=='type-jazler'){
var qtjazlerFolder=qtjazler.split('NowOnAir.xml').join('AlbumsCache/');
if(qtUseProxy){
qtjazler=proxyURL+'?qtproxycall='+window.btoa(qtjazler);
}
fn.log('==============================================================');
fn.log(qtjazler);
$.ajax({
type: "GET",
url:qtjazler,
dataType: "xml",
async: true,
cache: false,
success: function(xml){
fn.log(xml);
$(xml).find('Event').each(function(){
fn.log($(this));
var CacheImageFile=$(this).find('CacheImageFile').html();
$(this).find('Announcement').each(function(){
var title=$(this).attr('Display');
fn.log(title);
if(CacheImageFile&&'function'===typeof(callBack)){
fn.log(qtjazlerFolder + CacheImageFile);
$.qtMplayerGlobalSongData.thumbnail=qtjazlerFolder + CacheImageFile;
callBack(qtjazlerFolder + CacheImageFile);
callBack=false;
}
fn.qtApplyTitle(title , callBack);
});
});
},
error: function(e){
console.log('Jazler source unreachable - please check your channel settings');
console.log(e);
}});
return;
}
if(fd.servertype=='type-lautfm'){
fn.log('Server type: LAUT.FM');
fn.log('Stream URL: '+fd.file);
if(fd.file.indexOf('/stream.laut.fm/')!=-1){
fn.log('Laut.FM reading titles');
var radioname=fd.file.split('https').join('http').split('http://stream.laut.fm/').join('');
var radiourl='https://api.laut.fm/station/'+radioname+'/current_song';
if(qtUseProxy){
radiourl=proxyURL+'/?qtproxycall='+window.btoa(radiourl);
}
$.ajax({
type: 'GET',
url: radiourl,
async: true,
cache: false,
success: function(data){
fn.log('Laut.FM Success');
if('object'!==typeof(data)){
data=JSON.parse(data);
}
var titles='Now live - Streaming';
if(data.type){
if(data.type!=='jingle'){
if(data.title){
titles=data.title;
if(data.artist){
if(data.artist.name){
titles=data.artist.name +' - '+ titles;
}}
}
fn.qtApplyTitle(titles, callBack);
}}
},
error: function(e){
fn.log(e);
console.log(e);
fn.qtApplyTitle('Laut FM API error - Titles not available');
}});
}
return;
}
if(fd.servertype==='type-icy'){
fn.log('type-icy');
fn.log(proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1');
$.ajax({
type: 'GET',
url: proxyURL,
jsonpCallback: 'parseMusic',
async: true,
cache: false,
data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1'  },
success: function(data){
if(data==='Song title unavailable'||data==='Cannot open the stream'){
fn.log('ERROR OPENING THE STREAM OR GETTING THE TITLES: '+data);
fn.qtApplyTitle($.qtmplayerRadioFeedObj.qtFeedData.title, false);
callBack($.qtmplayerRadioFeedObj.qtFeedData.cover);
return;
}
fn.qtApplyTitle(data, callBack);
fn.log(data);
},
error: function(e){
console.log('Error');
fn.log(e);
console.log(e);
}});
}
if(fd.servertype=='type-auto'){
if(fd.file.indexOf('/proxy/')!=-1&&fd.file.indexOf('https')!=-1&&fd.file.indexOf('?mp=/')!=-1){
fn.log('type-auto TYPE 1 - GET MOUNTPOINT');
qtradiofeedHost=fd.file.split('?mp=/');
qtradiofeedHost=qtradiofeedHost[0] + '?mp=/stats' + '&rand='+timestamp;
if(qtUseProxy){
qtradiofeedHost=proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost);
}
$.ajax({
type: 'GET',
url: qtradiofeedHost,
async: true,
cache: false,
dataType: "xml",
success: function(data){
fn.qtApplyTitle($(data).find('SONGTITLE').html() , callBack);
if($(data).find('CURRENTLISTENERS')){
listeners=$(data).find('CURRENTLISTENERS').html();
}
if($(data).find('PEAKLISTENERS')){
listener_peak=$(data).find('PEAKLISTENERS').html();
}
fn.qtApplyListeners(listeners, listener_peak);
},
error: function(e){
fn.log(e);
console.log(e);
}});
}else if(fd.file.indexOf('/proxy/')==-1&&fd.file.indexOf('https')!=-1&&fd.file.endsWith('/stream')&&fd.file.indexOf('/mp3')==-1){
fn.log('type-auto TYPE 2 - XML:'+fd.file.endsWith('/stream')+'? ----> '+fd.file);
qtradiofeedHost=fd.file.replace(/\/stream$/, '/stats','$1');//     fd.file.split('/stream').join('/stats');
fn.log('Stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>');
if(qtUseProxy){
qtradiofeedHost=proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost);
}
fn.log('Proxy stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>');
$.ajax({
type: 'GET',
url: qtradiofeedHost,
async: true,
success: function(data){
if(data==='Song title unavailable'){
fn.qtApplyTitle($.qtmplayerRadioFeedObj.qtFeedData.title , false);
callBack($.qtmplayerRadioFeedObj.qtFeedData.cover);
return;
}
fn.qtApplyTitle($(data).find('SONGTITLE').html() , callBack);
if($(data).find('CURRENTLISTENERS')){
listeners=$(data).find('CURRENTLISTENERS').html();
}
if($(data).find('PEAKLISTENERS')){
listener_peak=$(data).find('PEAKLISTENERS').html();
}
fn.qtApplyListeners(listeners, listener_peak);
},
error: function(e){
fn.log(e);
console.log(e);
}});
}else{
fn.log('type-auto TYPE 3 ICY METADATA');
fn.log(proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1');
$.ajax({
type: 'GET',
url: proxyURL,
jsonpCallback: 'parseMusic',
async: true,
cache: false,
data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1'  },
success: function(data){
if(data==='Song title unavailable'){
fn.qtApplyTitle($.qtmplayerRadioFeedObj.qtFeedData.title, false);
callBack($.qtmplayerRadioFeedObj.qtFeedData.cover);
return;
}
fn.qtApplyTitle(data, callBack);
fn.log(data);
}});
}
return;
}
if(fd.servertype=='type-maxcast'){
fn.log('Maxcast '+ qtmaxcast);
qtmaxcast=qtmaxcast + '?rand='+timestamp;
if(qtUseProxy){
qtmaxcast=proxyURL+'?qtproxycall='+window.btoa(qtmaxcast);
}
$.ajax({
type: 'GET',
cache: false,
url: qtmaxcast,
async: true,
jsonpCallback: "parseMusic",
jsonp: false,
data: songdata,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
if(data.playing){
title=data.playing.current;
}
if(data.song_data&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.song_data.cover;
callBack(data.song_data.cover);
callBack=false;
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log(e);
}});
return;
}
if(qtradioboss===''&&qtsecuresystems===''&&qtradiojar===''&&qtradioking===''&&qtazuracast===''&&qttextfeed===''&&qtradionomy===''&&qtlive365===''&&qtairtime===''&&(qtradiofeedHost===''||qtradiofeedPort===''||typeof(qtradiofeedHost)==='undefined')&&qticecasturl===''&&qtradiodotco===''){
fn.qtApplyTitle();
return;
}else{
if(qtradioboss!==''){
qtradioboss=qtradioboss;
fn.log(qtradioboss);
if(qtUseProxy){
qtradioboss=proxyURL+'?qtproxycall='+window.btoa(qtradioboss);
}
$.ajax({
type: 'GET',
cache: false,
url: qtradioboss,
async: true,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
title=data['nowplaying'];
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log(e);
}});
return;
}
if(qtradiojar!==''){
if(qtradiojar.indexOf("?") > -1){
qtradiojar=qtradiojar + '&rand='+timestamp;
}else{
qtradiojar=qtradiojar + '?rand='+timestamp;
}
if(qtUseProxy){
qtradiojar=proxyURL+'?qtproxycall='+window.btoa(qtradiojar);
}
$.ajax({
type: 'GET',
cache: false,
url: qtradiojar,
async: true,
success: function(data){
if('object'!==typeof(data)){
data=JSON.parse(data);
}
var titles='Now live - Streaming';
if(data.title){
titles=data.title;
if(data.artist){
titles=data.artist+' - '+data.title;
}}
if(data.art&&'function'===typeof(callBack)){
if(data.title){
data.art=data.art + '?title=' + data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, '');
}
$.qtMplayerGlobalSongData.thumbnail=data.art;
callBack(data.art);
callBack=false;
}
if(data.thumb&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.thumb+'#.jpg';
callBack(data.thumb+'#.jpg');
callBack=false;
}
fn.qtApplyTitle(titles, callBack);
},
error: function(e){
console.log(e);
}});
}
if(qtsecuresystems!==''){
qtsecuresystems=qtsecuresystems;
if(qtUseProxy){
qtsecuresystems=proxyURL+'?qtproxycall='+window.btoa(qtsecuresystems);
}
$.ajax({
type: 'GET',
cache: false,
url: qtsecuresystems,
async: true,
dataType: "xml",
success: function(data){
if($(data).find('cover').length > 0){
if($(data).find('cover').html()!==''&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=$(data).find('cover').html();
callBack($(data).find('cover').html());
callBack=false;
}}
var title=$(data).find('title').html();
if('undefined'==typeof(title)||'undefined'==title){
title=$(data).find('name').html();
}
fn.qtApplyTitle($(data).find('artist').html()+ ' - ' +title  , callBack);
},
error: function(e){
console.log(e);
}});
return;
}
if(qtlive365!==''){
qtlive365='https://api.live365.com/station/'+qtlive365;
if(qtUseProxy){
qtlive365=proxyURL+'?qtproxycall='+window.btoa(qtlive365);
}
$.ajax({
type: 'GET',
cache: false,
url: qtlive365,
async: true,
jsonpCallback: "parseMusic",
jsonp: false,
success: function(data){
jsondata=data;
if('object'!==typeof(data)){
data=JSON.parse(data);
}
if(data['current-track'].art){
var art=data['current-track'].art;
if(art!=''){
$.qtMplayerGlobalSongData.thumbnail=art;
callBack(art);
callBack=false;
}}
fn.qtApplyTitle(data['current-track'].artist+' - '+data['current-track'].title, callBack);
},
error: function(e){
console.log(e);
}});
}
else if(qttextfeed!==''){
var tfeedurl,jsondata, title, proxyURL, mydata;
if(qtUseProxy){
tfeedurl=$("#qtmplayer-radiofeed-proxyurl").data('proxyurl');
mydata={
"qtproxycall": window.btoa(qttextfeed),
};}else{
tfeedurl=qttextfeed;
}
$.ajax({
type: 'GET',
cache: false,
url: tfeedurl,
async: true,
data: mydata,
dataType: "html",
success: function(data){
fn.qtApplyTitle(data, callBack);
},
error: function(e){
console.log(e);
}});
return;
}
else if(qtradionomy!==''){
$.ajax({
type: 'GET',
url: qtradionomy,
async: true,
cache: false,
dataType: "xml",
success: function(data){
fn.qtApplyTitle($(data).find('artists').html()+ ' - ' + $(data).find('title').html());
},
error: function(e){
console.log(e);
}});
}
else if(qtairtime!==''&&qtairtime!=='undefined'&&qtairtime!==undefined&&typeof(qtairtime)!=='undefined'){
var jsondata, title;
$.ajax({
type: 'GET',
cache: false,
url: qtairtime,
async: true,
data: {
"qtproxycall": window.btoa(qtairtime),
},
jsonpCallback: "parseMusic",
jsonp: true,
success: function(data){
if(typeof(data)!=='object'){
data=JSON.parse(data);
}
title=data.tracks.current.name;
fn.qtApplyTitle(title);
},
error: function(e){
}});
}
else if(qticecasturl!==''&&typeof(qticecasturl)!=='undefined'){
var feedurl=qticecasturl;
var source;
var title;
var songdata;
var listeners=false;
var listener_peak=false;
if(qtUseProxy){
feedurl=proxyURL;
songdata={
"qtproxycall":  window.btoa(qticecasturl),
};}
fn.log('Radio feed - Icecast '+ qticecasturl);
$.ajax({
type: 'GET',
cache: false,
url: feedurl,
async: true,
jsonpCallback: "parseMusic",
jsonp: false,
data: songdata,
success: function(json){
fn.log('Ajax response');
fn.log(json);
if('object'!==typeof(json)){
json=JSON.parse(json);
}
if('undefined'===typeof(json.icestats)){
if(qticecastmountpoint){
source=json[qticecastmountpoint];
}else{
$.each(json, function(index, element){
source=element;
if(index==0){
source=element;
}});
}}else{
source=json.icestats.source;
}
if('undefined'===typeof(source)){
return;
}
if(qticecastmountpoint){
source=source[qticecastmountpoint];
}
if(qticecastchannel){
source=source[qticecastchannel];
}
if(!qticecastchannel&&'undefined'===typeof(source.title)){
source=source[0];
}
title=source.title;
if(source.artist){
title=title + ' - ' + source.artist;
}
fn.qtApplyTitle(title, callBack);
if(source.listeners){
listeners=source.listeners;
}
if(source.listener_peak){
listener_peak=source.listener_peak;
}
fn.qtApplyListeners(listeners, listener_peak);
},error: function(e){
console.log(e);
fn.log('Ajax response');
fn.log(e);
}});
}
else if(qtradiofeedHost!==''&&qtradiofeedPort!==''&&typeof(qtradiofeedHost)!=='undefined'){
var feedData={
shoutcast_host: qtradiofeedHost,
shoutcast_port: qtradiofeedPort,
shoutcast_protocol: qtradiofeedProtocol,
shoutcast_channel: theChannel
};
var channel=feedData.shoutcast_channel||1;
var protocol='http';
if(feedData.shoutcast_port==='443'||feedData.shoutcast_protocol==='https'){
protocol='https';
}
var shoutcastUrl=protocol+'://'+feedData.shoutcast_host+':'+feedData.shoutcast_port+'/stats?sid='+channel+'&json=1';
var feedurl=shoutcastUrl;
if(qtUseProxy){
feedurl=proxyURL;
songdata={
"qtproxycall":  window.btoa(shoutcastUrl),
};}
try{
$.ajax({
type: 'GET',
cache: false,
url: feedurl,
async: true,
data: songdata,
dataType:  $.qtmplayerRadioFeedObj.qtFeedData.dataType,
contentType: "application/json",
success: function(json){
if('object'!==typeof(json)){
json=JSON.parse(json);
}
fn.qtApplyTitle(json.songtitle, callBack);
if(json.currentlisteners){
listeners=json.currentlisteners;
}
if(json.peaklisteners){
listener_peak=json.peaklisteners;
}
fn.qtApplyListeners(listeners, listener_peak);
},error: function(e){
if($.qtmplayerRadioFeedObj.qtFeedData.dataType!=='jsonp'){
$.qtmplayerRadioFeedObj.qtFeedData.dataType='jsonp';
$.qtmplayerRadioFeedObj.fn.newFeedReading();
}}
});
} catch(e){
dataType='jsonp';
console.log(e);
}
return;
}
else if(qtradiodotco!==''&&typeof(qtradiodotco)!=='undefined'){
var rUrl='https://public.radio.co/stations/'+qtradiodotco+'/status'
$.ajax({
type: 'GET',
cache: false,
url: rUrl,
async: true,
contentType: "application/json",
success: function(data){
if(data['current_track']){
title=data['current_track']['title'];
fn.log('Radio.co artwork: '+ data['current_track']['artwork_url_large']);
if(data['current_track']['artwork_url_large']&&'function'===typeof(callBack)){
var art=data['current_track']['artwork_url_large'];
if(art!==''){
$.qtMplayerGlobalSongData.thumbnail=art;
callBack(art);
callBack=false;
}}
}else{
title='Song title currently unavailable - Please check your radio settings';
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
}});
}
else if(fd.servertype=='type-radioking'&&qtradioking!==''){
var rUrl='https://api.radioking.io/widget/radio/'+qtradioking+'/track/current';
$.ajax({
type: 'GET',
cache: false,
url: rUrl,
async: true,
contentType: "application/json",
success: function(data){
title=data.artist+' - '+data.title;
if(data.cover&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.cover;
callBack(data.cover);
callBack=false;
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log(e);
}});
}
else if(fd.servertype=='type-azuracast'&&qtazuracast!==''){
var rUrl='';
var feedurl=qtazuracast + '?rand='+timestamp;
if(qtUseProxy){
feedurl=proxyURL+'?qtproxycall='+window.btoa(qtazuracast);
}
$.ajax({
type: 'GET',
cache: false,
url: feedurl,
async: true,
contentType: "application/json",
success: function(data){
if("string"==typeof(data)){
data=jQuery.parseJSON(data);
}
if('undefined'===typeof(data.now_playing) ){
data=data[0];
}
author=data.now_playing.song.artist;
title=data.now_playing.song.title;
if(''!==author){
title=author+' - '+title;
}
if(data.now_playing.song.cover&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.now_playing.song.cover;
callBack(data.now_playing.song.cover);
callBack=false;
}
if(data.now_playing.song.art&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.now_playing.song.art;
callBack(data.now_playing.song.art);
callBack=false;
}
if(data.cover&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.cover;
callBack(data.cover);
callBack=false;
}
if(data.art&&'function'===typeof(callBack)){
$.qtMplayerGlobalSongData.thumbnail=data.art;
callBack(data.art);
callBack=false;
}
if(data.listeners){
if(data.listeners.current){
listeners=data.listeners.current;
}
if(data.listeners.total){
listener_peak=data.listeners.total;
}
fn.qtApplyListeners(listeners, listener_peak);
}
fn.qtApplyTitle(title, callBack);
},
error: function(e){
console.log(e);
}});
}}
return;
},
feedInterval: null,
stopFeed: function(){
var o=$.qtmplayerRadioFeedObj;
if("undefined"!==typeof($.qtmplayerRadioFeedObj.fn.qtFeedInterval)){
clearInterval($.qtmplayerRadioFeedObj.fn.qtFeedInterval);
}},
pushFeed: function(data){
var o=$.qtmplayerRadioFeedObj;
o.qtFeedData=data;
o.fn.log('pushFeed=INITIALIZE'+$.now());
o.fn.log(data);
o.fn.stopFeed();
o.fn.newFeedReading();
o.fn.qtApplyListeners(false,false);
$.qtmplayerRadioFeedObj.qtFeedData.dataType='';
$.qtmplayerRadioFeedObj.fn.qtFeedInterval=setInterval(
function(){
o.fn.newFeedReading();
},
$.qtmplayerRadioFeedObj.timeInterval
);
},
log:function(msg){
var c=$("#qtmPlayerDebugger");
if(c.length > 0){
c.append(msg+'<br>');
}}
}};
$(document).ready(function(){
$.qtmplayerRadioFeedObj.fn.qtApplyTitle();
});
})(jQuery);