1/** 2* 3* @package qtmplayer 4* @subpackage qtmplayer-radiofeed 5* 6*/ 7 8(function($) { 9 "use strict"; 10 function isXML(xml){ 11 try { 12 xmlDoc = $.parseXML(xml); //is valid XML 13 return true; 14 } catch (err) { 15 // was not XML 16 return false; 17 } 18 } 19 20 21 22 $.qtmplayerRadioFeedObj = { 23 body: $("body"), 24 window: $(window), 25 document: $(document), 26 htmlAndbody: $('html,body'), 27 qtFeedData: {}, 28 timeInterval: 15000, 29 /** 30 * ======================================================================================================================================== | 31 * | 32 * | 33 * START SITE FUNCTIONS | 34 * | 35 * | 36 * ======================================================================================================================================== | 37 */ 38 fn: { 39 cachedThumbsArray: [], // when this changes, we fetch a new cover 40 updateMediaData(){ 41 // console.log( 'updateMediaData: ' ); 42 // console.log( $.qtMplayerGlobalSongData ); 43 if ('mediaSession' in navigator) { 44 if($.qtMplayerGlobalSongData.thumbnail && false !== $.qtMplayerGlobalSongData.thumbnail){ 45 // console.log('Yes art'); 46 navigator.mediaSession.metadata = new MediaMetadata({ 47 title: $.qtMplayerGlobalSongData.title, 48 artist: $.qtMplayerGlobalSongData.artist, 49 artwork: [ 50 { src: $.qtMplayerGlobalSongData.thumbnail, type: "image/jpeg" } 51 ] 52 }); 53 } else { 54 // console.log('No art'); 55 navigator.mediaSession.metadata = new MediaMetadata({ 56 title: $.qtMplayerGlobalSongData.title, 57 artist: $.qtMplayerGlobalSongData.artist 58 }); 59 } 60 } 61 }, 62 // ----------------------------------------------- FEED READERS END ------------------------------------ 63 getThumbnail: function(that, termArray, callBack){ 64 65 66 var preclean = termArray.split('<!--'); 67 if(preclean.length > 1){ 68 termArray = preclean[0]; 69 } 70 71 termArray = termArray.split(' - ').join('-').split(' ').join('+'); 72 73 var thumb; // image from itunes 74 75 var apiUrl; 76 77 78 apiUrl = 79 'https://itunes.apple.com/search' 80 + '?media=music' // limita al catalogo musica 81 + '&entity=album' // ritorna solo album 82 + '&attribute=albumTerm' // match sul titolo album 83 + '&limit=25' 84 + '&term=' + encodeURIComponent(termArray); 85 //console.log('Nerw'); 86 apiUrl = 'https://itunes.apple.com/search?limit=4&media=music&term='+termArray; 87 88 if(termArray == 'Song title unavailable' || termArray == 'No Titles Available'){ 89 thumb = $.qtmplayerRadioFeedObj.qtFeedData.cover; 90 that.cachedThumbsArray[termArray] = thumb; 91 $.qtMplayerGlobalSongData.thumbnail = thumb; 92 callBack(thumb); 93 return; 94 } 95 96 97 if( undefined === that.cachedThumbsArray[termArray] ) { 98 99 if( $.qtmplayerRadioFeedObj.qtFeedData.artwork ){ 100 termArray = termArray.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 101 callBack($.qtmplayerRadioFeedObj.qtFeedData.artwork+'?song='+termArray); 102 } else { 103 104 $.ajax({ 105 type: 'GET', 106 cache: true, 107 url: apiUrl, 108 async: true, 109 dataType: 'jsonp', 110 context: this, 111 success: function(json) { 112 if('object' !== typeof( json )){ 113 json = JSON.parse(json); 114 } 115 if(json.resultCount > 0){ 116 thumb = json.results[0].artworkUrl100.split('100x100bb.jpg').join('1000x1000bb.jpg'); 117 that.cachedThumbsArray[termArray] = thumb; 118 $.qtMplayerGlobalSongData.thumbnail = thumb; 119 120 121 callBack(thumb); 122 return; 123 } 124 } 125 }); 126 } 127 } else { 128 // return cached image 129 $.qtMplayerGlobalSongData.thumbnail = that.cachedThumbsArray[termArray]; 130 callBack( that.cachedThumbsArray[termArray] ); 131 return; 132 } 133 $.qtmplayerRadioFeedObj.fn.updateMediaData(); 134 }, 135 136 137 138 /**==================================================================== 139 * 140 * 141 * Marquee for longer texts 142 * 143 * 144 ====================================================================*/ 145 marqueeInstances: [], 146 marqueeText: function(that) { 147 if('function' !== typeof( $.fn.marquee ) ){ // missing marquee library? quit 148 return; 149 } 150 var marquees = $('body').find('.proradio-marquee'); 151 // Destroy any old instance of the marquee 152 if( that.marqueeInstances.length > 0 ){ 153 for( var mi = 0; mi < that.marqueeInstances.length; mi++ ){ 154 if( 'undefined' !== typeof( that.marqueeInstances[mi] )){ 155 that.marqueeInstances[mi].marquee('destroy'); 156 } 157 } 158 that.marqueeInstances = []; // reset 159 } 160 $.each(marquees, function(i,c){ 161 var item = $(c); 162 if(item.find('.marquee').length === 0){ 163 item.html('<span class="marquee">'+item.html()+'</span>'); 164 } 165 if( item.outerWidth() > item.find('.marquee').outerWidth() ){ // the title is short? quit! 166 return; 167 } 168 that.marqueeInstances[i] = item.marquee({ 169 duration: 20000, 170 gap: 150, 171 delayBeforeStart: 0, 172 direction: 'left', 173 duplicated: true, 174 pauseOnCycle: 0, 175 startVisible: true 176 }); 177 }); 178 }, 179 180 /** 181 * =======================================================
182 * Display listeners when available 183 * @since 2022 06 21 184 * ======================================================= 185 * */ 186 qtApplyListeners: function(listeners, listener_peak){ 187 if($.qtmplayerRadioFeedObj.qtFeedData.listeners || $.qtmplayerRadioFeedObj.qtFeedData.listenerspeak){ 188 if(listeners || listener_peak){ 189 $(".qtmplayer__stats").addClass('show'); 190 if(listeners && $.qtmplayerRadioFeedObj.qtFeedData.listeners){ 191 $('.qtmplayer-listeners span').html(listeners); 192 $('.qtmplayer-listeners').show(); 193 } else { 194 $('.qtmplayer-listeners').hide(); 195 } 196 if(listener_peak && $.qtmplayerRadioFeedObj.qtFeedData.listenerspeak){ 197 $('.qtmplayer-listener_peak span').html(listener_peak); 198 $('.qtmplayer-listener_peak').show(); 199 } else { 200 $('.qtmplayer-listener_peak').hide(); 201 } 202 return true; 203 } 204 } 205 $(".qtmplayer__stats").removeClass('show'); 206 $('.qtmplayer-listeners span').html(''); 207 $('.qtmplayer-listener_peak span').html(''); 208 return; 209 }, 210 211 212 qtApplyTitle: function(result, callBack){ 213 var that = this; 214 if(result && result !== ''){ 215 216 var dmes = '>>>>> qtApplyTitle : '+result; 217 $.qtmplayerRadioFeedObj.fn.log(dmes); 218 219 // result = decodeURIComponent(escape(result)); 220 var feedsplit = result.split(" - "); 221 var artist; 222 var title; 223 if(feedsplit.length > 1){ 224 artist = feedsplit[0], 225 title = feedsplit[1]; 226 } else { 227 feedsplit = result.split("-"); 228 if(feedsplit.length > 1){ 229 artist = feedsplit[0], 230 title = feedsplit[1]; 231 } else { 232 artist = ""; 233 title = result; 234 } 235 } 236 var artistSplit = artist.split('['); 237 if( artistSplit.length > 1 ){ 238 artist = artistSplit[0]; 239 } 240 artistSplit = artist.split(' : '); 241 if( artistSplit.length > 1 ){ 242 artist = artistSplit[1]; 243 } 244 var titleSplit = title.split('['); 245 if( titleSplit.length > 1 ){ 246 title = titleSplit[0]; 247 } 248 title = $.trim(title); 249 artist = $.trim(artist); 250 251 $(".qtmplayer-feed").show(); 252 $('.qtmplayer__title').html(title); 253 $('.qtmplayer__artist').html(artist); 254 255 256 257 258 that.marqueeText( that ); 259 var termArray = artist+'-'+title; 260 261 if( callBack ){ 262 this.getThumbnail(that, termArray, callBack ); 263 } 264 265 266 // Update media data ============================== 267 if (window.screen.width < 670 ) { 268 var uA = navigator.userAgent || navigator.vendor || window.opera; 269 if ( /Googlebot/i.test(uA) || /Bing/i.test(uA) || /Yandex/i.test(uA) || /Apple Bot/i.test(uA) || /DuckDuck Bot/i.test(uA) ){ 270 // Do nothing 271 } else { 272 jQuery(document).prop('title', artist+' - '+title); 273 } 274 } 275 $.qtMplayerGlobalSongData.title = title; 276 $.qtMplayerGlobalSongData.artist = artist; 277 $.qtmplayerRadioFeedObj.fn.updateMediaData(); 278 279 } else { 280 $(".qtmplayer-feed").hide(); 281 } 282 return; 283 }, 284 newFeedReading: function(){ 285 286 287 // debug: fix title not changing after pause 288 289 $.qtmplayerRadioFeedObj.fn.log('newFeedReading = REITERATE - '+$.now()); 290 // console.log( $.qtmplayerRadioFeedObj.qtFeedData ); 291 var o = $.qtmplayerRadioFeedObj, 292 fd = o.qtFeedData, 293 callBack = fd.callBack, 294 fn = o.fn, 295 qtradiofeedHost = (undefined !== fd.host) ? fd.host : '', 296 qtradiofeedPort = (undefined !== fd.port) ? fd.port : '', 297 qtradiofeedProtocol = (undefined !== fd.protocol) ? fd.protocol : 'http', 298 theChannel = (undefined !== fd.channel) ? fd.channel : '', 299 qticecasturl = (undefined !== fd.icecasturl) ? fd.icecasturl : '', 300 qticecastmountpoint = (undefined !== fd.icecastmountpoint) ? fd.icecastmountpoint : '', 301 qticecastchannel = (undefined !== fd.icecastchannel) ? fd.icecastchannel : '', 302 qtradiodotco = (undefined !== fd.radiodotco) ? fd.radiodotco : '', 303 qtairtime = (undefined !== fd.airtime) ? fd.airtime : '', 304 qtradionomy = (undefined !== fd.radionomy) ? fd.radionomy : '', 305 qttextfeed = (undefined !== fd.textfeed) ? fd.textfeed : '', 306 qtUseProxy = (undefined !== fd.useproxy) ? fd.useproxy : '', 307 qtlive365 = (undefined !== fd.live365) ? fd.live365 : '', 308 qtradioking = (undefined !== fd.radioking) ? fd.radioking : '', 309 qtazuracast = (undefined !== fd.azuracast) ? fd.azuracast : '', 310 qtsecuresystems = (undefined !== fd.securesystems) ? fd.securesystems : '', 311 qtradiojar = (undefined !== fd.radiojar) ? fd.radiojar : '', 312 qtradioboss = (undefined !== fd.radioboss) ? fd.radioboss : '', 313 qtmaxcast = (undefined !== fd.maxcast) ? fd.maxcast : '', 314 qtsonicpanel = (undefined !== fd.sonicpanel) ? fd.sonicpanel : '', 315 qtsonicpaneldj = (undefined !== fd.sonicpaneldj) ? fd.sonicpaneldj : '', 316 qtjazler = (undefined !== fd.jazler) ? fd.jazler : '', 317 qteverestcast = (undefined !== fd.everestcast) ? fd.everestcast : '', 318 qtstreamerr = (undefined !== fd.streamerr) ? fd.streamerr : '', 319 qtstreamguys_api = (undefined !== fd.streamguys_api) ? fd.streamguys_api : '', 320 qtstreamguys_uuid = (undefined !== fd.streamguys_uuid) ? fd.streamguys_uuid : '', 321 qtradiocult = (undefined !== fd.radiocult) ? fd.radiocult : '', 322 broadcastradio = (undefined !== fd.broadcastradio) ? fd.broadcastradio : '', 323 radiolize = (undefined !== fd.radiolize) ? fd.radiolize : '', 324 stationplaylist = (undefined !== fd.stationplaylist) ? fd.stationplaylist : '', 325 yesstreaming = (undefined !== fd.yesstreaming) ? fd.yesstreaming : '', 326 qtFeedPlayerTrack = $('#qtFeedPlayerTrack'), 327 qtFeedPlayerAuthor = $('#qtFeedPlayerAuthor'), 328 qtPlayerTrackInfo = $("#qtPlayerTrackInfo"), 329 author, title, result, feedsplit; 330 o = $.qtmplayerRadioFeedObj; 331 var proxyURL = $("#qtmplayer-radiofeed-proxyurl").data('proxyurl'); 332 var timestamp = new Date().getUTCMilliseconds(); 333 var listener_peak = false;
334 var listeners = false; 335 336 337 /** 338 * =================================================================== 339 * 340 * YesStreaming 341 * 342 * =================================================================== 343 */ 344 345 if( fd.servertype == 'type-yesstreaming' && yesstreaming ){ 346 if(qtUseProxy){ 347 yesstreaming = proxyURL+'?qtproxycall='+window.btoa(yesstreaming); //REQUIRED 348 } 349 $.ajax({ 350 type: 'GET', 351 cache: false, 352 url: yesstreaming, 353 async: true, 354 jsonp: "callback", 355 success: function(data) { 356 357 if (typeof data !== 'object') { 358 try { 359 data = JSON.parse(data); 360 } catch (e) { 361 console.log("Invalid JSON from Radiolize"); 362 return; 363 } 364 } 365 // console.log( data.results[0] ); 366 var results = data.results[0]; 367 var trackTitlte = data.results[0].metadata; 368 if( 'undefined' !== typeof(data.results[0].img_url) && data.results[0].img_url && 'function' === typeof(callBack) ){ 369 console.log( data.results[0].img_url ); 370 callBack( data.results[0].img_url ); 371 callBack = false; 372 } 373 if( trackTitlte ){ 374 fn.qtApplyTitle(trackTitlte, callBack); 375 } else { 376 console.log(yesstreaming); 377 console.log('Yesstreaming title not available'); 378 fn.qtApplyTitle('Title not available', callBack); 379 } 380 }, 381 error: function(e){ 382 console.log(yesstreaming); 383 console.log('Yesstreaming feed not loaded - error ahead:'); 384 console.log(e); 385 } 386 }); 387 return; 388 } 389 390 391 /** 392 * =================================================================== 393 * 394 * stationplaylist 395 * 396 * =================================================================== 397 */ 398 if( fd.servertype == 'type-stationplaylist' && stationplaylist ){ 399 if(qtUseProxy){ 400 stationplaylist = proxyURL+'?qtproxycall='+window.btoa(stationplaylist); //REQUIRED 401 } 402 403 404 $.ajax({ 405 type: "GET", 406 url:stationplaylist, 407 dataType: "xml", 408 async: true, 409 cache: false, 410 success: function(xml) { 411 fn.log(xml); 412 $(xml).find('Current').each(function(){ 413 fn.log($(this)); 414 var song = $(this); 415 var title = song.find('Title').html(); 416 var artist = song.find('Artist').html(); 417 var artwork = song.find('Image'); 418 419 if(artwork){ 420 artwork = artwork.html(); 421 if(artwork != ''){ 422 callBack( artwork ); 423 callBack = false; 424 } 425 } 426 fn.qtApplyTitle(title + ' - ' + artist , callBack); 427 }); 428 }, 429 error: function(e){ 430 console.log('stationplaylist source unreachable - please check your channel settings'); 431 console.log(e); 432 } 433 }); 434 return; 435 } 436 437 438 /** 439 * =================================================================== 440 * 441 * Radiolize 442 * 443 * =================================================================== 444 */ 445 if( fd.servertype == 'type-radiolize' && radiolize ){ 446 if(qtUseProxy){ 447 radiolize = proxyURL+'?qtproxycall='+window.btoa(radiolize); //REQUIRED 448 } 449 $.ajax({ 450 type: 'GET', 451 url: radiolize, 452 cache: false, 453 async: true, 454 dataType: 'json', 455 success: function(data) { 456 if (typeof data !== 'object') { 457 try { 458 data = JSON.parse(data); 459 } catch (e) { 460 console.log("Invalid JSON from Radiolize"); 461 return; 462 } 463 } 464 465 if (!data.now_playing || !data.now_playing.song || !data.now_playing.song.text) { 466 fn.log("Missing data for Radiolize song title"); 467 return; 468 } 469 470 var title = data.now_playing.song.text; 471 472 if (typeof data.now_playing.song.art !== 'undefined' && data.now_playing.song.art && typeof callBack === 'function') { 473 var img = data.now_playing.song.art; 474 $.qtMplayerGlobalSongData.thumbnail = img; 475 callBack(img); 476 callBack = false;
477 } 478 479 fn.qtApplyTitle(title, callBack); 480 }, 481 error: function(e) { 482 console.log('Broadcast.Radio feed not loaded - error ahead:'); 483 console.log(e); 484 } 485 }); 486 487 return; 488 } 489 490 /** 491 * =================================================================== 492 * 493 * Broadcast.Radio 494 * 495 * =================================================================== 496 */ 497 if( fd.servertype == 'type-broadcastradio' && broadcastradio ){ 498 if(qtUseProxy){ 499 broadcastradio = proxyURL+'?qtproxycall='+window.btoa(broadcastradio); //REQUIRED 500 } 501 $.ajax({ 502 type: 'GET', 503 cache: false, 504 url: broadcastradio, 505 async: true, 506 jsonp: true, 507 success: function(data) { 508 if('object' !== typeof( data )){ 509 data = JSON.parse(data); 510 } 511 if(!data.success){ 512 fn.log("Missing data for Broadcast.Radio song title"); 513 return; 514 } 515 title = data.body.now_playing.title; 516 if(data.body.now_playing.artist ){ 517 title = title +' - ' + data.body.now_playing.artist; 518 } 519 if( 'undefined' !== typeof(data.body.now_playing.artworkUrl) && data.body.now_playing.artworkUrl && 'function' === typeof(callBack) ){ 520 if( 'undefined' !== typeof( data.body.now_playing.artworkUrl ) ){ 521 if( data.body.now_playing.artworkUrl ){ 522 var img = data.body.now_playing.artworkUrl; 523 $.qtMplayerGlobalSongData.thumbnail = img; 524 callBack( img ); 525 callBack = false; 526 } 527 } 528 } 529 fn.qtApplyTitle(title, callBack); 530 }, 531 error: function(e){ 532 console.log('Broadcast.Radio feed not loaded - error ahead:'); 533 console.log(e); 534 } 535 }); 536 return; 537 } 538 539 540 541 /** 542 * =================================================================== 543 * 544 * RadioCult 545 * 546 * =================================================================== 547 */ 548 if( fd.servertype == 'type-radiocult' && qtradiocult ){ 549 // if(qtUseProxy){ 550 qtradiocult = proxyURL+'?qtproxycall='+window.btoa(qtradiocult); //REQUIRED 551 // } 552 $.ajax({ 553 type: 'GET', 554 cache: false, 555 url: qtradiocult, 556 async: true, 557 jsonp: true, 558 success: function(data) { 559 if('object' !== typeof( data )){ 560 data = JSON.parse(data); 561 } 562 if(!data.result.metadata){ 563 fn.log("Missing data for Radiocult song title"); 564 return; 565 } 566 title = data.result.metadata.title; 567 568 if(data.result.metadata.artist ){ 569 title = title +' - ' + data.result.metadata.artist; 570 } 571 if( 'undefined' !== typeof(data.result.metadata.artwork) && data.result.metadata.artwork && 'function' === typeof(callBack) ){ 572 if( 'undefined' !== typeof(data.result.metadata.artwork.original ) ){ 573 if( data.result.metadata.artwork.original ){ 574 var img = data.result.metadata.artwork.original; 575 $.qtMplayerGlobalSongData.thumbnail = img; 576 callBack( img ); 577 callBack = false; 578 } 579 } 580 } 581 fn.qtApplyTitle(title, callBack); 582 }, 583 error: function(e){ 584 console.log('Streamguys feed not loaded - error ahead:'); 585 console.log(e); 586 } 587 }); 588 return; 589 } 590 /** 591 * =================================================================== 592 * 593 * SteamGuys 594 * 595 * =================================================================== 596 */ 597 if( fd.servertype == 'type-streamguys' && qtstreamguys_api && qtstreamguys_uuid ){ 598 var apiurl = 'https://jetapi.streamguys.com/'+qtstreamguys_api+'/scraper/'+qtstreamguys_uuid+'/metadata/raw/'; 599 600 if(qtUseProxy){ 601 apiurl = proxyURL+'?qtproxycall='+window.btoa(apiurl); 602 } 603 $.ajax({ 604 type: 'GET', 605 cache: false, 606 url: apiurl, 607 async: true, 608 jsonp: true, 609 success: function(text) { 610 if(text == '{"error":"API Key not found."}'){ 611 return; 612 } 613 // Regular expression to match the StreamTitle value 614 var match = text.match(/StreamTitle='(.*?)'/); 615 var title = match ? match[1] : ""; 616 fn.qtApplyTitle(title, callBack); 617 }, 618 error: function(e){ 619 console.log('Streamguys feed not loaded - error ahead:'); 620 console.log(e); 621 } 622 }); 623 return; 624 } 625 626 /** 627 * =================================================================== 628 * 629 * EverestCast 630 * 631 * =================================================================== 632 */ 633 if( fd.servertype == 'type-everestcast' ){ 634 fn.log(qteverestcast); 635 if(qtUseProxy){ 636 qteverestcast = proxyURL+'?qtproxycall='+window.btoa(qteverestcast); 637 } 638 $.ajax({ 639 type: 'GET', 640 cache: false, 641 url: qteverestcast, 642 async: true, 643 jsonp: true, 644 success: function(data) { 645 if('object' !== typeof( data )){ 646 data = JSON.parse(data); 647 } 648 649 if(!data.current_track.title){ 650 fn.log("Missing data for Everestcast song title"); 651 return; 652 } 653 title = data.current_track.title; 654 if(data.current_track.image && 'function' === typeof(callBack)){ 655 656 $.qtMplayerGlobalSongData.thumbnail = data.current_track.image; 657 callBack( data.current_track.image ); 658 callBack = false;
659 } 660 fn.qtApplyTitle(title, callBack); 661 }, 662 error: function(e){ 663 console.log('MediaCP feed not loaded - error ahead:'); 664 console.log(e); 665 } 666 }); 667 return; 668 } 669 670 671 /** 672 * =================================================================== 673 * 674 * MediaCP 675 * 676 * =================================================================== 677 */ 678 if( fd.servertype == 'type-mediacp' ){ 679 fn.log(qtmediacp); 680 if(qtUseProxy){ 681 qtmediacp = proxyURL+'?qtproxycall='+window.btoa(qtmediacp); 682 } 683 $.ajax({ 684 type: 'GET', 685 cache: false, 686 url: qtmediacp, 687 async: true, 688 jsonp: true, 689 success: function(data) { 690 if('object' !== typeof( data )){ 691 data = JSON.parse(data); 692 } 693 fn.log(data); 694 title = data.nowplaying; 695 if(data.coverart && 'function' === typeof(callBack)){ 696 $.qtMplayerGlobalSongData.thumbnail = data.coverart; 697 callBack( data.coverart ); 698 699 callBack = false; 700 } 701 fn.qtApplyTitle(title, callBack); 702 }, 703 error: function(e){ 704 console.log('MediaCP feed not loaded - error ahead:'); 705 console.log(e); 706 } 707 }); 708 return; 709 } 710 711 712 713 /** 714 * =================================================================== 715 * 716 * Streamerr 717 * 718 * =================================================================== 719 */ 720 if( fd.servertype == 'type-streamerr' ){ 721 fn.log(qtstreamerr); 722 if(qtUseProxy){ 723 qtstreamerr = proxyURL+'?qtproxycall='+window.btoa(qtstreamerr); 724 } 725 $.ajax({ 726 type: 'GET', 727 cache: false, 728 url: qtstreamerr, 729 async: true, 730 jsonp: true, 731 success: function(data) { 732 733 if('object' !== typeof( data )){ 734 data = JSON.parse(data); 735 } 736 737 fn.log(data); 738 title = data.nowplaying; 739 if(data.coverart && 'function' === typeof(callBack)){ 740 $.qtMplayerGlobalSongData.thumbnail = data.coverart; 741 callBack( data.coverart ); 742 743 callBack = false; 744 } 745 fn.qtApplyTitle(title, callBack); 746 }, 747 error: function(e){ 748 console.log('Streamerr not working - error ahead:'); 749 console.log(e); 750 } 751 }); 752 return; 753 } 754 755 756 757 /** 758 * =================================================================== 759 * 760 * sonicpanel 761 * 762 * =================================================================== 763 */ 764 if( fd.servertype == 'type-sonicpanel' ){ 765 if( qtsonicpanel !== ''){ 766 if ( qtsonicpanel.indexOf("?") > -1 ) { 767 qtsonicpanel = qtsonicpanel + '&rand='+timestamp; 768 } else { 769 qtsonicpanel = qtsonicpanel + '?rand='+timestamp; 770 } 771 if(qtUseProxy){ 772 qtsonicpanel = proxyURL+'?qtproxycall='+window.btoa(qtsonicpanel); 773 } 774 $.ajax({ 775 type: 'GET', 776 cache: false, 777 url: qtsonicpanel, 778 async: true, 779 success: function(data) { 780 if('object' !== typeof( data )){ 781 data = JSON.parse(data); 782 } 783 var titles = 'Now live - Streaming'; 784 if(data.title){ 785 titles = data.title; 786 if(data.artist){ 787 titles = data.artist+' - '+data.title; 788 } 789 } 790 if(data.art && 'function' === typeof(callBack)){ 791 if(data.title){ 792 data.art = data.art + '?title=' + data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 793 } 794 $.qtMplayerGlobalSongData.thumbnail = data.art; 795 callBack(data.art); 796 797 callBack = false; 798 } 799 if(data.thumb && 'function' === typeof(callBack)){ 800 $.qtMplayerGlobalSongData.thumbnail = data.thumb+'#.jpg'; 801 callBack(data.thumb+'#.jpg'); 802 803 callBack = false; 804 } 805 if( '1' == qtsonicpaneldj && data.djusername !== 'No DJ'){ 806 titles = data.title.split(' - ').join(' / ')+' - '+data.djusername; 807 } 808 if(data.listn){ 809 listeners = data.listn; 810 } 811 if(data.peaklistn){ 812 listener_peak = data.peaklistn; 813 } 814 fn.qtApplyListeners(listeners, listener_peak); 815 fn.qtApplyTitle(titles, callBack); 816 }, 817 error: function(e){ 818 console.log(e); 819 } 820 }); 821 } 822 } 823 824 825 /** 826 * =================================================================== 827 * 828 * qtjazler 829 * 830 * =================================================================== 831 */ 832 if( fd.servertype == 'type-jazler' ){ 833 var qtjazlerFolder = qtjazler.split('NowOnAir.xml').join('AlbumsCache/'); 834 if(qtUseProxy){ 835 qtjazler = proxyURL+'?qtproxycall='+window.btoa(qtjazler); 836 } 837 fn.log('=============================================================='); 838 fn.log(qtjazler); 839 $.ajax({ 840 type: "GET", 841 url:qtjazler, 842 dataType: "xml", 843 async: true, 844 cache: false, 845 success: function(xml) { 846 fn.log(xml); 847 $(xml).find('Event').each(function(){ 848 fn.log($(this)); 849 var CacheImageFile = $(this).find('CacheImageFile').html(); 850 $(this).find('Announcement').each(function(){ 851 var title = $(this).attr('Display'); 852 fn.log(title); 853 if(CacheImageFile && 'function' === typeof(callBack) ){ 854 fn.log(qtjazlerFolder + CacheImageFile); 855 856 $.qtMplayerGlobalSongData.thumbnail = qtjazlerFolder + CacheImageFile; 857 callBack( qtjazlerFolder + CacheImageFile ); 858 callBack = false;
859 } 860 fn.qtApplyTitle(title , callBack); 861 }); 862 863 }); 864 }, 865 error: function(e){ 866 console.log('Jazler source unreachable - please check your channel settings'); 867 console.log(e); 868 } 869 }); 870 return; 871 } 872 873 874 /** 875 * =================================================================== 876 * 877 * laut.FM 878 * 879 * =================================================================== 880 */ 881 if( fd.servertype == 'type-lautfm' ){ 882 fn.log('Server type: LAUT.FM'); 883 fn.log('Stream URL: '+fd.file); 884 if( fd.file.indexOf('/stream.laut.fm/') != -1 ){ 885 fn.log('Laut.FM reading titles'); 886 var radioname = fd.file.split('https').join('http').split('http://stream.laut.fm/').join(''); 887 var radiourl = 'https://api.laut.fm/station/'+radioname+'/current_song'; 888 // if ( radiourl.indexOf("?") > -1 ) { 889 // radiourl = radiourl + '&rand='+timestamp; 890 // } else { 891 // radiourl = radiourl + '?rand='+timestamp; 892 // } 893 if(qtUseProxy){ 894 radiourl = proxyURL+'/?qtproxycall='+window.btoa(radiourl); 895 } 896 // console.log(radiourl); 897 $.ajax({ 898 type: 'GET', 899 url: radiourl, 900 async: true, 901 cache: false, 902 success: function(data) { 903 fn.log('Laut.FM Success'); 904 if('object' !== typeof( data )){ 905 data = JSON.parse(data); 906 } 907 var titles = 'Now live - Streaming'; 908 909 if(data.type){ 910 if(data.type !== 'jingle'){ 911 if(data.title){ 912 titles = data.title; 913 if(data.artist){ 914 if(data.artist.name){ 915 titles = data.artist.name +' - '+ titles; 916 } 917 } 918 } 919 fn.qtApplyTitle( titles, callBack ); 920 } 921 } 922 923 }, 924 error: function(e){ 925 fn.log(e); 926 console.log(e); 927 fn.qtApplyTitle('Laut FM API error - Titles not available'); 928 } 929 }); 930 } 931 return; 932 } // IF servertype end 933 934 935 936 if( fd.servertype === 'type-icy' ){ 937 938 939 fn.log('type-icy'); 940 fn.log( proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1' ); 941 $.ajax({ 942 type: 'GET', 943 url: proxyURL, 944 jsonpCallback: 'parseMusic', 945 async: true, 946 cache: false, 947 data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1' }, 948 success: function(data) { 949 if(data === 'Song title unavailable' || data === 'Cannot open the stream' ){ 950 fn.log('ERROR OPENING THE STREAM OR GETTING THE TITLES: '+data); 951 fn.qtApplyTitle( $.qtmplayerRadioFeedObj.qtFeedData.title, false ); 952 callBack( $.qtmplayerRadioFeedObj.qtFeedData.cover ); 953 return; 954 } 955 fn.qtApplyTitle( data, callBack ); 956 fn.log(data); 957 }, 958 error: function(e){ 959 console.log('Error'); 960 fn.log(e); 961 console.log(e); 962 } 963 }); 964 } 965 966 967 968 /** 969 * =================================================================== 970 * 971 * Auto or HTTPS shoutcast 972 * 973 * =================================================================== 974 */ 975 if( fd.servertype == 'type-auto' ){ 976 if(fd.file.indexOf('/proxy/') != -1 && fd.file.indexOf('https') != -1 && fd.file.indexOf('?mp=/') != -1){ 977 fn.log('type-auto TYPE 1 - GET MOUNTPOINT'); 978 979 qtradiofeedHost = fd.file.split('?mp=/'); 980 qtradiofeedHost = qtradiofeedHost[0] + '?mp=/stats' + '&rand='+timestamp; 981 if(qtUseProxy){ 982 qtradiofeedHost = proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost); 983 } 984 $.ajax({ 985 type: 'GET', 986 url: qtradiofeedHost, 987 async: true, 988 cache: false, 989 dataType: "xml", 990 success: function(data) { 991 992 993 fn.qtApplyTitle( $(data).find('SONGTITLE').html() , callBack); 994 995 // Listeners ====================================== 996 if($(data).find('CURRENTLISTENERS')){ 997 listeners = $(data).find('CURRENTLISTENERS').html(); 998 } 999 if($(data).find('PEAKLISTENERS')){ 1000 listener_peak = $(data).find('PEAKLISTENERS').html(); 1001 } 1002 fn.qtApplyListeners(listeners, listener_peak); 1003 1004 }, 1005 error: function(e){ 1006 fn.log(e); 1007 console.log(e); 1008 } 1009 }); 1010 } else if(fd.file.indexOf('/proxy/') == -1 && fd.file.indexOf('https') != -1 && fd.file.endsWith('/stream') && fd.file.indexOf('/mp3') == -1 ){ 1011 1012 fn.log('type-auto TYPE 2 - XML:'+fd.file.endsWith('/stream')+'? ----> '+fd.file); 1013 1014 1015 1016 // OLD system 1017 // qtradiofeedHost = fd.file.split('/stream'); 1018 // qtradiofeedHost = qtradiofeedHost[0] + '/stats'; // no random here
1019 // NEW - replace only the last occurrence of /stream 1020 qtradiofeedHost = fd.file.replace(/\/stream$/, '/stats','$1');// fd.file.split('/stream').join('/stats'); 1021 1022 1023 fn.log('Stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>'); 1024 1025 if(qtUseProxy){ 1026 qtradiofeedHost = proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost); 1027 } 1028 fn.log('Proxy stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>'); 1029 $.ajax({ 1030 type: 'GET', 1031 url: qtradiofeedHost, 1032 async: true, 1033 //cache: false, 1034 //dataType: "xml", 1035 success: function(data) { 1036 1037 1038 if(data === 'Song title unavailable' ){ 1039 fn.qtApplyTitle( $.qtmplayerRadioFeedObj.qtFeedData.title , false); 1040 callBack( $.qtmplayerRadioFeedObj.qtFeedData.cover ); 1041 return; 1042 } 1043 1044 1045 fn.qtApplyTitle( $(data).find('SONGTITLE').html() , callBack); 1046 1047 1048 // Listeners ====================================== 1049 if($(data).find('CURRENTLISTENERS')){ 1050 listeners = $(data).find('CURRENTLISTENERS').html(); 1051 } 1052 if($(data).find('PEAKLISTENERS')){ 1053 listener_peak = $(data).find('PEAKLISTENERS').html(); 1054 } 1055 fn.qtApplyListeners(listeners, listener_peak); 1056 1057 }, 1058 error: function(e){ 1059 fn.log(e); 1060 console.log(e); 1061 } 1062 }); 1063 1064 } else { 1065 fn.log('type-auto TYPE 3 ICY METADATA'); 1066 1067 1068 fn.log( proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1' ); 1069 $.ajax({ 1070 type: 'GET', 1071 url: proxyURL, 1072 jsonpCallback: 'parseMusic', 1073 async: true, 1074 cache: false, 1075 data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1' }, 1076 success: function(data) { 1077 if(data === 'Song title unavailable' ){ 1078 fn.qtApplyTitle( $.qtmplayerRadioFeedObj.qtFeedData.title, false ); 1079 callBack( $.qtmplayerRadioFeedObj.qtFeedData.cover ); 1080 return; 1081 } 1082 fn.qtApplyTitle( data, callBack ); 1083 fn.log(data); 1084 } 1085 }); 1086 1087 } 1088 return; 1089 } 1090 1091 /** 1092 * Maxcast 1093 */ 1094 /** 1095 * =================================================================== 1096 * 1097 * Maxcast 1098 * 1099 * =================================================================== 1100 */ 1101 // Demo feeds: 1102 //https://s05.maxcast.com.br/api/status/brasitaliawebradio/current.json 1103 //https://s16.maxcast.com.br/api/status/bocadoacreatualjt/current.json 1104 if( fd.servertype == 'type-maxcast' ){ 1105 fn.log('Maxcast '+ qtmaxcast); 1106 qtmaxcast = qtmaxcast + '?rand='+timestamp; 1107 if(qtUseProxy){ 1108 qtmaxcast = proxyURL+'?qtproxycall='+window.btoa(qtmaxcast); // working without proxy. Leave here just in case 1109 } 1110 $.ajax({ 1111 type: 'GET', 1112 cache: false, 1113 url: qtmaxcast, 1114 async: true, 1115 jsonpCallback: "parseMusic", 1116 jsonp: false, 1117 data: songdata, 1118 success: function(data) { 1119 if('object' !== typeof(data)){ 1120 data = JSON.parse(data); 1121 } 1122 if(data.playing){ 1123 title = data.playing.current; 1124 } 1125 if(data.song_data && 'function' === typeof(callBack)){ 1126 1127 $.qtMplayerGlobalSongData.thumbnail = data.song_data.cover; 1128 callBack( data.song_data.cover ); 1129 callBack = false; 1130 } 1131 fn.qtApplyTitle(title, callBack); 1132 }, 1133 error: function(e){ 1134 console.log(e); 1135 } 1136 }); 1137 return; 1138 } 1139 1140 if(qtradioboss === '' && qtsecuresystems === '' && qtradiojar === '' && qtradioking === '' && qtazuracast === '' && qttextfeed === '' && qtradionomy === '' && qtlive365 === '' && qtairtime === '' && (qtradiofeedHost === '' || qtradiofeedPort === '' || typeof(qtradiofeedHost) === 'undefined') && qticecasturl === '' && qtradiodotco === '') { 1141 fn.qtApplyTitle(); 1142 return; 1143 } else { 1144 1145 1146 1147 1148 1149 /** 1150 * =================================================================== 1151 * 1152 * Radioboss 1153 * 1154 * =================================================================== 1155 */ 1156 if( qtradioboss !== ''){ 1157 qtradioboss = qtradioboss;// + '?rand='+timestamp; 1158 fn.log(qtradioboss); 1159 1160 if(qtUseProxy){ 1161 qtradioboss = proxyURL+'?qtproxycall='+window.btoa(qtradioboss); 1162 } 1163 1164 // qtradioboss = proxyURL+'?qtproxycall='+window.btoa(qtradioboss); 1165 $.ajax({ 1166 type: 'GET', 1167 cache: false, 1168 url: qtradioboss, 1169 async: true, 1170 // contentType: "application/json", 1171 // jsonp: true, 1172 success: function(data) { 1173 if('object' !== typeof( data )){ 1174 data = JSON.parse(data); 1175 } 1176 title = data['nowplaying']; 1177 fn.qtApplyTitle(title, callBack); 1178 }, 1179 error: function(e){ 1180 console.log(e); 1181 } 1182 }); 1183 return; 1184 } 1185 1186 1187 1188 1189 1190 /** 1191 * =================================================================== 1192 * 1193 * Radiojar 1194 * 1195 * =================================================================== 1196 */ 1197 if( qtradiojar !== ''){ 1198 if ( qtradiojar.indexOf("?") > -1 ) { 1199 qtradiojar = qtradiojar + '&rand='+timestamp; 1200 } else { 1201 qtradiojar = qtradiojar + '?rand='+timestamp; 1202 } 1203 if(qtUseProxy){ 1204 qtradiojar = proxyURL+'?qtproxycall='+window.btoa(qtradiojar); 1205 } 1206 $.ajax({ 1207 type: 'GET', 1208 cache: false, 1209 url: qtradiojar, 1210 async: true, 1211 success: function(data) { 1212 if('object' !== typeof( data )){ 1213 data = JSON.parse(data); 1214 } 1215 var titles = 'Now live - Streaming'; 1216 if(data.title){ 1217 titles = data.title; 1218 if(data.artist){ 1219 titles = data.artist+' - '+data.title; 1220 } 1221 } 1222 if(data.art && 'function' === typeof(callBack)){ 1223 if(data.title){ 1224 data.art = data.art + '?title=' + data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 1225 } 1226 1227 $.qtMplayerGlobalSongData.thumbnail = data.art; 1228 callBack(data.art); 1229 callBack = false;
1230 } 1231 if(data.thumb && 'function' === typeof(callBack)){ 1232 1233 $.qtMplayerGlobalSongData.thumbnail = data.thumb+'#.jpg'; 1234 callBack(data.thumb+'#.jpg'); 1235 callBack = false; 1236 } 1237 fn.qtApplyTitle(titles, callBack); 1238 }, 1239 error: function(e){ 1240 console.log(e); 1241 } 1242 }); 1243 } 1244 1245 1246 1247 1248 /** 1249 * =================================================================== 1250 * 1251 * SecureSystems 1252 * 1253 * =================================================================== 1254 */ 1255 if( qtsecuresystems !== ''){ 1256 qtsecuresystems =qtsecuresystems; 1257 if(qtUseProxy){ 1258 qtsecuresystems = proxyURL+'?qtproxycall='+window.btoa(qtsecuresystems); 1259 } 1260 $.ajax({ 1261 type: 'GET', 1262 cache: false, 1263 url: qtsecuresystems, 1264 async: true, 1265 dataType: "xml", 1266 success: function(data) { 1267 if( $(data).find('cover').length > 0 ){ 1268 if($(data).find('cover').html() !== '' && 'function' === typeof(callBack)){ 1269 1270 $.qtMplayerGlobalSongData.thumbnail = $(data).find('cover').html(); 1271 callBack($(data).find('cover').html()); 1272 callBack = false; 1273 } 1274 } 1275 var title = $(data).find('title').html(); 1276 if( 'undefined' == typeof(title) || 'undefined' == title ){ 1277 title = $(data).find('name').html(); 1278 } 1279 fn.qtApplyTitle( $(data).find('artist').html()+ ' - ' +title , callBack); 1280 }, 1281 error: function(e){ 1282 console.log(e); 1283 } 1284 }); 1285 return; 1286 } 1287 1288 1289 1290 1291 1292 /** 1293 * =================================================================== 1294 * 1295 * qtlive365 1296 * 1297 * =================================================================== 1298 */ 1299 if( qtlive365 !== ''){ 1300 qtlive365 = 'https://api.live365.com/station/'+qtlive365; 1301 if(qtUseProxy){ 1302 qtlive365 = proxyURL+'?qtproxycall='+window.btoa(qtlive365); 1303 } 1304 1305 $.ajax({ 1306 type: 'GET', 1307 cache: false, 1308 url: qtlive365, 1309 async: true, 1310 jsonpCallback: "parseMusic", 1311 jsonp: false, 1312 success: function(data) { 1313 // console.log(data); 1314 jsondata = data; 1315 // console.log(json); 1316 if('object' !== typeof( data )){ 1317 data = JSON.parse(data); 1318 } 1319 if( data['current-track'].art ){ 1320 var art = data['current-track'].art; 1321 if( art != ''){ 1322 1323 // console.log(art); 1324 $.qtMplayerGlobalSongData.thumbnail = art; 1325 callBack(art); 1326 callBack = false; 1327 } 1328 } 1329 fn.qtApplyTitle(data['current-track'].artist+' - '+data['current-track'].title, callBack); 1330 }, 1331 error: function(e){ 1332 console.log(e); 1333 } 1334 }); 1335 } 1336 1337 /** 1338 * =================================================================== 1339 * 1340 * Text 1341 * 1342 * =================================================================== 1343 */ 1344 else if(qttextfeed !== ''){ 1345 var tfeedurl,jsondata, title, proxyURL, mydata; 1346 if(qtUseProxy){ 1347 tfeedurl = $("#qtmplayer-radiofeed-proxyurl").data('proxyurl'); 1348 mydata = { 1349 "qtproxycall": window.btoa(qttextfeed), 1350 }; 1351 } else { 1352 tfeedurl = qttextfeed; 1353 } 1354 $.ajax({ 1355 type: 'GET', 1356 cache: false, 1357 url: tfeedurl, 1358 async: true, 1359 data: mydata, 1360 dataType: "html", 1361 success: function(data) { 1362 fn.qtApplyTitle( data, callBack ); 1363 }, 1364 error: function(e){ 1365 console.log(e); 1366 } 1367 }); 1368 return; 1369 } 1370 /** 1371 * =================================================================== 1372 * 1373 * Radionomy 1374 * 1375 * =================================================================== 1376 */ 1377 else if(qtradionomy !== '' ) { 1378 $.ajax({ 1379 type: 'GET', 1380 url: qtradionomy, 1381 async: true, 1382 cache: false, 1383 dataType: "xml", 1384 success: function(data) { 1385 fn.qtApplyTitle( $(data).find('artists').html()+ ' - ' + $(data).find('title').html() ); 1386 }, 1387 error: function(e){ 1388 console.log(e); 1389 } 1390 }); 1391 } 1392 1393 /** 1394 * =================================================================== 1395 * 1396 * AirTime 1397 * 1398 * =================================================================== 1399 */ 1400 else if(qtairtime !== '' && qtairtime !== 'undefined' && qtairtime !== undefined && typeof(qtairtime) !== 'undefined'){ 1401 var jsondata, title; 1402 $.ajax({ 1403 type: 'GET', 1404 cache: false, 1405 url: qtairtime,//proxyURL, 1406 async: true, 1407 data: { 1408 "qtproxycall": window.btoa(qtairtime), 1409 }, 1410 jsonpCallback: "parseMusic", 1411 jsonp: true,//jsonp: true, 1412 // contentType: "application/json", 1413 success: function(data) { 1414 // console.log(data); 1415 if(typeof(data) !== 'object'){ 1416 data = JSON.parse(data); 1417 } 1418 title = data.tracks.current.name; 1419 fn.qtApplyTitle(title); 1420 }, 1421 error: function(e) { 1422 } 1423 }); 1424 } 1425 1426 /** 1427 * =================================================================== 1428 * 1429 * Icecast 1430 * 1431 * =================================================================== 1432 */ 1433 else if(qticecasturl !== '' && typeof(qticecasturl) !== 'undefined') { 1434 var feedurl = qticecasturl; 1435 var source; 1436 var title; 1437 var songdata; 1438 var listeners = false;
1439 var listener_peak = false; 1440 if(qtUseProxy){ 1441 feedurl = proxyURL; 1442 songdata = { 1443 "qtproxycall": window.btoa(qticecasturl), 1444 }; 1445 } 1446 // beta 1447 fn.log('Radio feed - Icecast '+ qticecasturl); 1448 // generally ok, not working for LN Soulr Icecast 1449 // console.log( proxyURL+'?qtproxycall='+window.btoa(qticecasturl) ); 1450 $.ajax({ 1451 type: 'GET', 1452 cache: false, 1453 url: feedurl, 1454 async: true, 1455 jsonpCallback: "parseMusic", 1456 jsonp: false,//jsonp: true, 1457 // dataType: 'jsonp', // not working with some radios 1458 data: songdata, 1459 // contentType: "application/json", 1460 success: function(json) { 1461 fn.log('Ajax response'); 1462 fn.log( json ); 1463 1464 // console.log(json); 1465 if('object' !== typeof( json )){ 1466 json = JSON.parse(json); 1467 } 1468 if('undefined' === typeof(json.icestats)){ 1469 // This is Icecast HK 1470 1471 if(qticecastmountpoint){ 1472 source = json[qticecastmountpoint]; 1473 } else { 1474 1475 $.each(json, function(index, element) { 1476 source = element; 1477 if(index == 0){ 1478 source = element; 1479 } 1480 }); 1481 // console.log(source); 1482 } 1483 } else { 1484 source = json.icestats.source; 1485 } 1486 1487 if('undefined' === typeof(source)){ 1488 return; 1489 } 1490 if(qticecastmountpoint){ 1491 source = source[qticecastmountpoint]; 1492 } 1493 if(qticecastchannel){ 1494 // console.log("set source to 0"); 1495 source = source[qticecastchannel]; 1496 } 1497 // since PR.3.2.3 1498 // If there is no channel and there is no title, channel must be 0 1499 if(!qticecastchannel && 'undefined' === typeof(source.title)){ 1500 source = source[0]; 1501 } 1502 title = source.title; 1503 if( source.artist ){ 1504 title = title + ' - ' + source.artist; 1505 } 1506 fn.qtApplyTitle(title, callBack); 1507 // Listeners ====================================== 1508 if(source.listeners){ 1509 listeners = source.listeners; 1510 } 1511 if(source.listener_peak){ 1512 listener_peak = source.listener_peak; 1513 } 1514 fn.qtApplyListeners(listeners, listener_peak); 1515 1516 },error: function(e) { 1517 console.log(e); 1518 fn.log('Ajax response'); 1519 fn.log( e ); 1520 } 1521 }); 1522 } 1523 /** 1524 * =================================================================== 1525 * 1526 * ShoutCast 1527 * 1528 * =================================================================== 1529 */ 1530 else if (qtradiofeedHost !== '' && qtradiofeedPort !== '' && typeof(qtradiofeedHost) !== 'undefined'){ 1531 // to tide up 1532 var feedData = { 1533 shoutcast_host: qtradiofeedHost, 1534 shoutcast_port: qtradiofeedPort, 1535 shoutcast_protocol: qtradiofeedProtocol, 1536 shoutcast_channel: theChannel 1537 }; 1538 var channel = feedData.shoutcast_channel || 1; 1539 var protocol = 'http'; 1540 if(feedData.shoutcast_port === '443' || feedData.shoutcast_protocol === 'https' ){ 1541 protocol = 'https'; 1542 } 1543 var shoutcastUrl = protocol+'://'+feedData.shoutcast_host+':'+feedData.shoutcast_port+'/stats?sid='+channel+'&json=1'; 1544 var feedurl = shoutcastUrl; 1545 1546 if(qtUseProxy){ 1547 feedurl = proxyURL; 1548 songdata = { 1549 "qtproxycall": window.btoa(shoutcastUrl), 1550 }; 1551 } 1552 1553 /** 1554 * @since PR.3.4.6 2021 02 27 added fallback 1555 */ 1556 try{ 1557 1558 $.ajax({ 1559 type: 'GET', 1560 cache: false, 1561 url: feedurl, 1562 async: true, 1563 data: songdata, 1564 dataType: $.qtmplayerRadioFeedObj.qtFeedData.dataType, 1565 contentType: "application/json", 1566 success: function(json) { 1567 if('object' !== typeof( json )){ 1568 json = JSON.parse(json); 1569 } 1570 fn.qtApplyTitle( json.songtitle, callBack); 1571 // Listeners ====================================== 1572 if(json.currentlisteners){ 1573 listeners = json.currentlisteners; 1574 } 1575 if(json.peaklisteners){ 1576 listener_peak = json.peaklisteners; 1577 } 1578 fn.qtApplyListeners(listeners, listener_peak); 1579 },error: function(e) { 1580 if($.qtmplayerRadioFeedObj.qtFeedData.dataType !== 'jsonp'){ 1581 $.qtmplayerRadioFeedObj.qtFeedData.dataType = 'jsonp'; 1582 $.qtmplayerRadioFeedObj.fn.newFeedReading(); 1583 } 1584 } 1585 }); 1586 } catch(e){ 1587 dataType = 'jsonp'; 1588 console.log(e); 1589 } 1590 1591 return; 1592 } 1593 /** 1594 * =================================================================== 1595 * 1596 * Radio.co 1597 * 1598 * =================================================================== 1599 */ 1600 else if (qtradiodotco !== '' && typeof(qtradiodotco) !== 'undefined'){ 1601 var rUrl = 'https://public.radio.co/stations/'+qtradiodotco+'/status' 1602 $.ajax({ 1603 type: 'GET', 1604 cache: false, 1605 url: rUrl, 1606 async: true, 1607 contentType: "application/json", 1608 success: function(data) { 1609 if( data['current_track'] ){ 1610 title = data['current_track']['title']; 1611 fn.log( 'Radio.co artwork: '+ data['current_track']['artwork_url_large'] ); 1612 if( data['current_track']['artwork_url_large'] && 'function' === typeof(callBack) ){ 1613 var art = data['current_track']['artwork_url_large']; 1614 if( art !== ''){ 1615 1616 $.qtMplayerGlobalSongData.thumbnail = art; 1617 callBack( art ); 1618 callBack = false;
1619 } 1620 } 1621 } else { 1622 title = 'Song title currently unavailable - Please check your radio settings'; 1623 } 1624 fn.qtApplyTitle(title, callBack); 1625 }, 1626 error: function(e) { 1627 } 1628 }); 1629 } 1630 /** 1631 * =================================================================== 1632 * 1633 * Radioking 1634 * 1635 * =================================================================== 1636 */ 1637 else if (fd.servertype == 'type-radioking' && qtradioking !== '' ){ 1638 var rUrl = 'https://api.radioking.io/widget/radio/'+qtradioking+'/track/current'; 1639 $.ajax({ 1640 type: 'GET', 1641 cache: false, 1642 url: rUrl, 1643 async: true, 1644 contentType: "application/json", 1645 success: function(data) { 1646 title = data.artist+' - '+data.title; 1647 if(data.cover && 'function' === typeof(callBack)){ 1648 1649 $.qtMplayerGlobalSongData.thumbnail = data.cover; 1650 callBack(data.cover); 1651 callBack = false; 1652 } 1653 fn.qtApplyTitle(title, callBack); 1654 }, 1655 error: function(e) { 1656 console.log(e); 1657 } 1658 }); 1659 } 1660 /** 1661 * =================================================================== 1662 * 1663 * Azuracast 1664 * 1665 * =================================================================== 1666 */ 1667 else if (fd.servertype == 'type-azuracast' && qtazuracast !== '' ){ 1668 var rUrl = ''; 1669 var feedurl = qtazuracast + '?rand='+timestamp; 1670 1671 if(qtUseProxy){ 1672 feedurl = proxyURL+'?qtproxycall='+window.btoa(qtazuracast); 1673 } 1674 $.ajax({ 1675 type: 'GET', 1676 cache: false, 1677 url: feedurl, 1678 async: true, 1679 contentType: "application/json", 1680 success: function(data) { 1681 if("string" == typeof(data)){ 1682 data = jQuery.parseJSON( data ); 1683 } 1684 if( 'undefined' === typeof( data.now_playing ) ){ 1685 data = data[0]; 1686 } 1687 author = data.now_playing.song.artist; 1688 title = data.now_playing.song.title; 1689 if('' !== author){ 1690 title = author+' - '+title; 1691 } 1692 if(data.now_playing.song.cover && 'function' === typeof(callBack)){ 1693 $.qtMplayerGlobalSongData.thumbnail = data.now_playing.song.cover; 1694 callBack(data.now_playing.song.cover); 1695 1696 callBack = false; 1697 } 1698 if(data.now_playing.song.art && 'function' === typeof(callBack)){ 1699 // console.log(data.now_playing.song.art); 1700 $.qtMplayerGlobalSongData.thumbnail = data.now_playing.song.art; 1701 callBack(data.now_playing.song.art); 1702 1703 callBack = false; 1704 } 1705 1706 if(data.cover && 'function' === typeof(callBack)){ 1707 $.qtMplayerGlobalSongData.thumbnail = data.cover; 1708 callBack(data.cover); 1709 1710 callBack = false; 1711 } 1712 if(data.art && 'function' === typeof(callBack)){ 1713 $.qtMplayerGlobalSongData.thumbnail = data.art; 1714 callBack(data.art); 1715 1716 callBack = false; 1717 } 1718 1719 // Listeners ====================================== 1720 if(data.listeners){ 1721 if(data.listeners.current){ 1722 listeners = data.listeners.current; 1723 } 1724 if(data.listeners.total){ 1725 listener_peak = data.listeners.total; 1726 } 1727 1728 fn.qtApplyListeners(listeners, listener_peak); 1729 } 1730 1731 1732 fn.qtApplyTitle(title, callBack); 1733 }, 1734 error: function(e) { 1735 console.log(e); 1736 1737 } 1738 }); 1739 } 1740 } 1741 return; 1742 }, 1743 feedInterval: null, 1744 stopFeed: function(){ 1745 var o = $.qtmplayerRadioFeedObj; 1746 if("undefined" !== typeof($.qtmplayerRadioFeedObj.fn.qtFeedInterval) ){ 1747 clearInterval($.qtmplayerRadioFeedObj.fn.qtFeedInterval); 1748 } 1749 1750 }, 1751 pushFeed: function( data ){ 1752 1753 var o = $.qtmplayerRadioFeedObj; 1754 o.qtFeedData = data; 1755 o.fn.log('pushFeed = INITIALIZE'+$.now()); 1756 o.fn.log(data); 1757 o.fn.stopFeed(); 1758 o.fn.newFeedReading(); 1759 o.fn.qtApplyListeners(false,false); 1760 $.qtmplayerRadioFeedObj.qtFeedData.dataType = ''; 1761 $.qtmplayerRadioFeedObj.fn.qtFeedInterval = setInterval( 1762 function(){ 1763 o.fn.newFeedReading(); 1764 }, 1765 $.qtmplayerRadioFeedObj.timeInterval 1766 ); 1767 }, 1768 log:function(msg){ 1769 var c = $("#qtmPlayerDebugger"); 1770 if(c.length > 0){
1771 c.append(msg+'<br>'); 1772 } 1773 } 1774 } 1775 1776 }; 1777 $(document).ready(function(){ 1778 $.qtmplayerRadioFeedObj.fn.qtApplyTitle(); 1779 }); 1780})(jQuery); 1781 1782 1783 1784 1785
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.