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 $.qtmplayerRadioFeedObj = { 22 body: $("body"), 23 window: $(window), 24 document: $(document), 25 htmlAndbody: $('html,body'), 26 qtFeedData: {}, 27 timeInterval: 15000, 28 /** 29 * ======================================================================================================================================== | 30 * | 31 * | 32 * START SITE FUNCTIONS | 33 * | 34 * | 35 * ======================================================================================================================================== | 36 */ 37 fn: { 38 cachedThumbsArray: [], // when this changes, we fetch a new cover 39 40 // ----------------------------------------------- FEED READERS END ------------------------------------ 41 getThumbnail: function(that, termArray, callBack){ 42 var preclean = termArray.split('<!--'); 43 if(preclean.length > 1){ 44 termArray = preclean[0]; 45 } 46 47 48 termArray = termArray.split(' - ').join('-').split(' ').join('+'); 49 var thumb; // image from itunes 50 var apiUrl = 'https://itunes.apple.com/search?term='+termArray; 51 if( undefined === that.cachedThumbsArray[termArray] ) { 52 $.ajax({ 53 type: 'GET', 54 cache: true, 55 url: apiUrl, 56 async: true, 57 dataType: 'jsonp', 58 context: this, 59 success: function(json) { 60 if('object' !== typeof( json )){ 61 json = JSON.parse(json); 62 } 63 if(json.resultCount > 0){ 64 thumb = json.results[0].artworkUrl100.split('100x100bb.jpg').join('1000x1000bb.jpg'); 65 that.cachedThumbsArray[termArray] = thumb; 66 callBack(thumb); 67 return; 68 } 69 } 70 }); 71 } else { 72 // return cached image 73 callBack( that.cachedThumbsArray[termArray] ); 74 return; 75 } 76 }, 77 78 79 80 /**==================================================================== 81 * 82 * 83 * Marquee for longer texts 84 * 85 * 86 ====================================================================*/ 87 marqueeInstances: [], 88 marqueeText: function(that) { 89 if('function' !== typeof( $.fn.marquee ) ){ // missing marquee library? quit 90 return; 91 } 92 var marquees = $('body').find('.proradio-marquee'); 93 // Destroy any old instance of the marquee 94 if( that.marqueeInstances.length > 0 ){ 95 for( var mi = 0; mi < that.marqueeInstances.length; mi++ ){ 96 if( 'undefined' !== typeof( that.marqueeInstances[mi] )){ 97 that.marqueeInstances[mi].marquee('destroy'); 98 } 99 } 100 that.marqueeInstances = []; // reset 101 } 102 $.each(marquees, function(i,c){ 103 var item = $(c); 104 if(item.find('.marquee').length === 0){ 105 item.html('<span class="marquee">'+item.html()+'</span>'); 106 } 107 if( item.outerWidth() > item.find('.marquee').outerWidth() ){ // the title is short? quit! 108 return; 109 } 110 that.marqueeInstances[i] = item.marquee({ 111 duration: 12000, 112 gap: item.outerWidth(), 113 delayBeforeStart: 1000, 114 direction: 'left', 115 duplicated: false, 116 pauseOnCycle: 5000, 117 startVisible: true 118 }); 119 }); 120 }, 121 122 qtApplyTitle: function(result, callBack){ 123 var that = this; 124 if(result && result !== ''){ 125 126 var dmes = '>>>>> qtApplyTitle : '+result; 127 $.qtmplayerRadioFeedObj.fn.log(dmes); 128 129 // result = decodeURIComponent(escape(result)); 130 var feedsplit = result.split(" - "); 131 var artist; 132 var title; 133 if(feedsplit.length > 1){ 134 artist = feedsplit[0], 135 title = feedsplit[1]; 136 } else { 137 feedsplit = result.split("-"); 138 if(feedsplit.length > 1){ 139 artist = feedsplit[0], 140 title = feedsplit[1]; 141 } else { 142 artist = ""; 143 title = result; 144 } 145 146 } 147 var artistSplit = artist.split('['); 148 if( artistSplit.length > 1 ){ 149 artist = artistSplit[0]; 150 } 151 artistSplit = artist.split(' : '); 152 if( artistSplit.length > 1 ){ 153 artist = artistSplit[1]; 154 } 155 var titleSplit = title.split('['); 156 if( titleSplit.length > 1 ){ 157 title = titleSplit[0]; 158 } 159 title = $.trim(title); 160 artist = $.trim(artist); 161 162 163 164 165 $(".qtmplayer-feed").show(); 166 $('.qtmplayer__title').html(title); 167 $('.qtmplayer__artist').html(artist); 168 that.marqueeText( that ); 169 var termArray = artist+'-'+title; 170 if( callBack ){ 171 this.getThumbnail(that, termArray, callBack ); 172 } 173 } else { 174 $(".qtmplayer-feed").hide(); 175 } 176 return; 177 }, 178 newFeedReading: function(){ 179 180 181 // debug: fix title not changing after pause 182 183 $.qtmplayerRadioFeedObj.fn.log('newFeedReading = REITERATE - '+$.now()); 184 185 var o = $.qtmplayerRadioFeedObj, 186 fd = o.qtFeedData, 187 callBack = fd.callBack, 188 fn = o.fn, 189 qtradiofeedHost = (undefined !== fd.host) ? fd.host : '', 190 qtradiofeedPort = (undefined !== fd.port) ? fd.port : '', 191 qtradiofeedProtocol = (undefined !== fd.protocol) ? fd.protocol : 'http', 192 theChannel = (undefined !== fd.channel) ? fd.channel : '', 193 qticecasturl = (undefined !== fd.icecasturl) ? fd.icecasturl : '', 194 qticecastmountpoint = (undefined !== fd.icecastmountpoint) ? fd.icecastmountpoint : '', 195 qticecastchannel = (undefined !== fd.icecastchannel) ? fd.icecastchannel : '', 196 qtradiodotco = (undefined !== fd.radiodotco) ? fd.radiodotco : '', 197 qtairtime = (undefined !== fd.airtime) ? fd.airtime : '', 198 qtradionomy = (undefined !== fd.radionomy) ? fd.radionomy : '', 199 qttextfeed = (undefined !== fd.textfeed) ? fd.textfeed : '', 200 qtUseProxy = (undefined !== fd.useproxy) ? fd.useproxy : '', 201 qtlive365 = (undefined !== fd.live365) ? fd.live365 : '', 202 qtradioking = (undefined !== fd.radioking) ? fd.radioking : '', 203 qtazuracast = (undefined !== fd.azuracast) ? fd.azuracast : '', 204 qtsecuresystems = (undefined !== fd.securesystems) ? fd.securesystems : '', 205 qtradiojar = (undefined !== fd.radiojar) ? fd.radiojar : '', 206 qtradioboss = (undefined !== fd.radioboss) ? fd.radioboss : '', 207 qtmaxcast = (undefined !== fd.maxcast) ? fd.maxcast : '', 208 209 qtjazler = (undefined !== fd.jazler) ? fd.jazler : '', 210 qtstreamerr = (undefined !== fd.streamerr) ? fd.streamerr : '', 211 qtFeedPlayerTrack = $('#qtFeedPlayerTrack'), 212 qtFeedPlayerAuthor = $('#qtFeedPlayerAuthor'), 213 qtPlayerTrackInfo = $("#qtPlayerTrackInfo"), 214 author, title, result, feedsplit; 215 o = $.qtmplayerRadioFeedObj; 216 var proxyURL = $("#qtmplayer-radiofeed-proxyurl").data('proxyurl'); 217 var timestamp = new Date().getUTCMilliseconds(); 218 219 /** 220 * =================================================================== 221 * 222 * Streamerr 223 * 224 * =================================================================== 225 */ 226 if( fd.servertype == 'type-streamerr' ){ 227 fn.log(qtstreamerr); 228 if(qtUseProxy){ 229 qtstreamerr = proxyURL+'?qtproxycall='+window.btoa(qtstreamerr); 230 } 231 $.ajax({ 232 type: 'GET', 233 cache: false, 234 url: qtstreamerr, 235 async: true, 236 jsonp: true, 237 success: function(data) { 238 fn.log(data); 239 title = data.nowplaying; 240 if(data.coverart && 'function' === typeof(callBack)){ 241 callBack( data.coverart ); 242 callBack = false;
243 } 244 fn.qtApplyTitle(title, callBack); 245 }, 246 error: function(e){ 247 console.log('Streamerr not working - error ahead:'); 248 console.log(e); 249 } 250 }); 251 return; 252 } 253 254 255 /** 256 * =================================================================== 257 * 258 * qtjazler 259 * 260 * =================================================================== 261 */ 262 if( fd.servertype == 'type-jazler' ){ 263 var qtjazlerFolder = qtjazler.split('NowOnAir.xml').join('AlbumsCache/'); 264 if(qtUseProxy){ 265 qtjazler = proxyURL+'?qtproxycall='+window.btoa(qtjazler); 266 } 267 fn.log('=============================================================='); 268 fn.log(qtjazler); 269 $.ajax({ 270 type: "GET", 271 url:qtjazler, 272 dataType: "xml", 273 async: true, 274 cache: false, 275 success: function(xml) { 276 fn.log(xml); 277 $(xml).find('Event').each(function(){ 278 fn.log($(this)); 279 var CacheImageFile = $(this).find('CacheImageFile').html(); 280 $(this).find('Announcement').each(function(){ 281 var title = $(this).attr('Display'); 282 fn.log(title); 283 if(CacheImageFile && 'function' === typeof(callBack) ){ 284 fn.log(qtjazlerFolder + CacheImageFile); 285 callBack( qtjazlerFolder + CacheImageFile ); 286 callBack = false; 287 } 288 fn.qtApplyTitle(title , callBack); 289 }); 290 291 }); 292 }, 293 error: function(e){ 294 console.log('Jazler source unreachable - please check your channel settings'); 295 console.log(e); 296 } 297 }); 298 return; 299 } 300 301 302 /** 303 * =================================================================== 304 * 305 * laut.FM 306 * 307 * =================================================================== 308 */ 309 if( fd.servertype == 'type-lautfm' ){ 310 fn.log('Server type: LAUT.FM'); 311 fn.log('Stream URL: '+fd.file); 312 if( fd.file.indexOf('/stream.laut.fm/') != -1 ){ 313 fn.log('Laut.FM reading titles'); 314 var radioname = fd.file.split('https').join('http').split('http://stream.laut.fm/').join(''); 315 var radiourl = 'https://api.laut.fm/station/'+radioname+'/current_song'; 316 // if ( radiourl.indexOf("?") > -1 ) { 317 // radiourl = radiourl + '&rand='+timestamp; 318 // } else { 319 // radiourl = radiourl + '?rand='+timestamp; 320 // } 321 if(qtUseProxy){ 322 radiourl = proxyURL+'/?qtproxycall='+window.btoa(radiourl); 323 } 324 // console.log(radiourl); 325 console.log(radiourl); 326 $.ajax({ 327 type: 'GET', 328 url: radiourl, 329 async: true, 330 cache: false, 331 success: function(data) { 332 fn.log('Laut.FM Success'); 333 if('object' !== typeof( data )){ 334 data = JSON.parse(data); 335 } 336 var titles = 'Now live - Streaming'; 337 if(data.title){ 338 titles = data.title; 339 if(data.artist){ 340 if(data.artist.name){ 341 titles = data.artist.name +' - '+ titles; 342 } 343 } 344 } 345 fn.qtApplyTitle( titles, callBack ); 346 }, 347 error: function(e){ 348 fn.log(e); 349 console.log(e); 350 fn.qtApplyTitle('Laut FM API error - Titles not available'); 351 } 352 }); 353 } 354 return; 355 } // IF servertype end 356 357 358 359 if( fd.servertype === 'type-icy' ){ 360 fn.log('type-icy'); 361 fn.log( proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1' ); 362 $.ajax({ 363 type: 'GET', 364 url: proxyURL, 365 jsonpCallback: 'parseMusic', 366 async: true, 367 cache: false, 368 data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1' }, 369 success: function(data) { 370 fn.qtApplyTitle( data, callBack ); 371 fn.log(data); 372 }, 373 error: function(e){ 374 fn.log(e); 375 console.log(e); 376 } 377 }); 378 } 379 380 381 382 /** 383 * =================================================================== 384 * 385 * Auto or HTTPS shoutcast 386 * 387 * =================================================================== 388 */ 389 if( fd.servertype == 'type-auto' ){ 390 if(fd.file.indexOf('/proxy/') != -1 && fd.file.indexOf('https') != -1 && fd.file.indexOf('?mp=/') != -1){ 391 fn.log('type-auto TYPE 1 - GET MOUNTPOINT'); 392 393 qtradiofeedHost = fd.file.split('?mp=/'); 394 qtradiofeedHost = qtradiofeedHost[0] + '?mp=/stats' + '&rand='+timestamp; 395 if(qtUseProxy){ 396 qtradiofeedHost = proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost); 397 } 398 $.ajax({ 399 type: 'GET', 400 url: qtradiofeedHost, 401 async: true, 402 cache: false, 403 dataType: "xml", 404 success: function(data) { 405 fn.qtApplyTitle( $(data).find('SONGTITLE').html() , callBack); 406 }, 407 error: function(e){ 408 fn.log(e); 409 console.log(e); 410 } 411 }); 412 } else if(fd.file.indexOf('/proxy/') == -1 && fd.file.indexOf('https') != -1 && fd.file.endsWith('/stream') && fd.file.indexOf('/mp3') == -1 ){ 413 414 fn.log('type-auto TYPE 2 - XML:'+fd.file.endsWith('/stream')+'? ----> '+fd.file); 415 416 417 418 419 // OLD system 420 // qtradiofeedHost = fd.file.split('/stream'); 421 // qtradiofeedHost = qtradiofeedHost[0] + '/stats'; // no random here
422 // NEW - replace only the last occurrence of /stream 423 qtradiofeedHost = fd.file.replace(/\/stream$/, '/stats','$1');// fd.file.split('/stream').join('/stats'); 424 425 426 fn.log('Stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>'); 427 428 if(qtUseProxy){ 429 qtradiofeedHost = proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost); 430 } 431 fn.log('Proxy stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>'); 432 $.ajax({ 433 type: 'GET', 434 url: qtradiofeedHost, 435 async: true, 436 //cache: false, 437 //dataType: "xml", 438 success: function(data) { 439 440 fn.qtApplyTitle( $(data).find('SONGTITLE').html() , callBack); 441 }, 442 error: function(e){ 443 fn.log(e); 444 console.log(e); 445 } 446 }); 447 448 } else { 449 450 fn.log('type-auto TYPE 3 ICY METADATA'); 451 452 453 fn.log( proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1' ); 454 $.ajax({ 455 type: 'GET', 456 url: proxyURL, 457 jsonpCallback: 'parseMusic', 458 async: true, 459 cache: false, 460 data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1' }, 461 success: function(data) { 462 fn.qtApplyTitle( data, callBack ); 463 fn.log(data); 464 } 465 }); 466 467 } 468 return; 469 } 470 471 /** 472 * Maxcast 473 */ 474 /** 475 * =================================================================== 476 * 477 * Maxcast 478 * 479 * =================================================================== 480 */ 481 // Demo feeds: 482 //https://s05.maxcast.com.br/api/status/brasitaliawebradio/current.json 483 //https://s16.maxcast.com.br/api/status/bocadoacreatualjt/current.json 484 if( fd.servertype == 'type-maxcast' ){ 485 fn.log('Maxcast '+ qtmaxcast); 486 qtmaxcast = qtmaxcast + '?rand='+timestamp; 487 if(qtUseProxy){ 488 qtmaxcast = proxyURL+'?qtproxycall='+window.btoa(qtmaxcast); // working without proxy. Leave here just in case 489 } 490 $.ajax({ 491 type: 'GET', 492 cache: false, 493 url: qtmaxcast, 494 async: true, 495 jsonpCallback: "parseMusic", 496 jsonp: false, 497 data: songdata, 498 success: function(data) { 499 if('object' !== typeof(data)){ 500 data = JSON.parse(data); 501 } 502 if(data.playing){ 503 title = data.playing.current; 504 } 505 if(data.song_data && 'function' === typeof(callBack)){ 506 callBack( data.song_data.cover ); 507 callBack = false; 508 } 509 fn.qtApplyTitle(title, callBack); 510 }, 511 error: function(e){ 512 console.log(e); 513 } 514 }); 515 return; 516 } 517 518 if(qtradioboss === '' && qtsecuresystems === '' && qtradiojar === '' && qtradioking === '' && qtazuracast === '' && qttextfeed === '' && qtradionomy === '' && qtlive365 === '' && qtairtime === '' && (qtradiofeedHost === '' || qtradiofeedPort === '' || typeof(qtradiofeedHost) === 'undefined') && qticecasturl === '' && qtradiodotco === '') { 519 fn.qtApplyTitle(); 520 return; 521 } else { 522 523 524 525 526 527 /** 528 * =================================================================== 529 * 530 * Radioboss 531 * 532 * =================================================================== 533 */ 534 if( qtradioboss !== ''){ 535 qtradioboss = qtradioboss;// + '?rand='+timestamp; 536 fn.log(qtradioboss); 537 538 if(qtUseProxy){ 539 qtradioboss = proxyURL+'?qtproxycall='+window.btoa(qtradioboss); 540 } 541 542 // qtradioboss = proxyURL+'?qtproxycall='+window.btoa(qtradioboss); 543 $.ajax({ 544 type: 'GET', 545 cache: false, 546 url: qtradioboss, 547 async: true, 548 // contentType: "application/json", 549 // jsonp: true, 550 success: function(data) { 551 if('object' !== typeof( data )){ 552 data = JSON.parse(data); 553 } 554 title = data['nowplaying']; 555 fn.qtApplyTitle(title, callBack); 556 }, 557 error: function(e){ 558 console.log(e); 559 } 560 }); 561 return; 562 } 563 564 565 /** 566 * =================================================================== 567 * 568 * Radiojar 569 * 570 * =================================================================== 571 */ 572 if( qtradiojar !== ''){ 573 574 if ( qtradiojar.indexOf("?") > -1 ) { 575 qtradiojar = qtradiojar + '&rand='+timestamp; 576 } else { 577 qtradiojar = qtradiojar + '?rand='+timestamp; 578 } 579 580 581 if(qtUseProxy){ 582 qtradiojar = proxyURL+'?qtproxycall='+window.btoa(qtradiojar); 583 } 584 585 586 $.ajax({ 587 type: 'GET', 588 cache: false, 589 url: qtradiojar, 590 async: true, 591 // contentType: "application/json", 592 success: function(data) { 593 if('object' !== typeof( data )){ 594 data = JSON.parse(data); 595 } 596 597 var titles = 'Now live - Streaming'; 598 if(data.title){ 599 titles = data.title; 600 if(data.artist){ 601 titles = data.artist+' - '+data.title; 602 } 603 } 604 605 if(data.art && 'function' === typeof(callBack)){ 606 607 if(data.title){ 608 data.art = data.art + '?title=' + data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 609 } 610 // console.log(data.art); 611 callBack(data.art); 612 callBack = false;
613 } 614 615 616 if(data.thumb && 'function' === typeof(callBack)){ 617 callBack(data.thumb+'#.jpg'); 618 callBack = false; 619 } 620 fn.qtApplyTitle(titles, callBack); 621 }, 622 error: function(e){ 623 console.log(e); 624 } 625 }); 626 } 627 628 629 630 631 /** 632 * =================================================================== 633 * 634 * SecureSystems 635 * 636 * =================================================================== 637 */ 638 if( qtsecuresystems !== ''){ 639 qtsecuresystems =qtsecuresystems; 640 if(qtUseProxy){ 641 qtsecuresystems = proxyURL+'?qtproxycall='+window.btoa(qtsecuresystems); 642 } 643 $.ajax({ 644 type: 'GET', 645 cache: false, 646 url: qtsecuresystems, 647 async: true, 648 dataType: "xml", 649 success: function(data) { 650 if($(data).find('cover').html() !== '' && 'function' === typeof(callBack)){ 651 callBack($(data).find('cover').html()); 652 callBack = false; 653 } 654 fn.qtApplyTitle( $(data).find('artist').html()+ ' - ' + $(data).find('title').html() , callBack); 655 }, 656 error: function(e){ 657 console.log(e); 658 } 659 }); 660 return; 661 } 662 663 664 665 666 667 /** 668 * =================================================================== 669 * 670 * qtlive365 671 * 672 * =================================================================== 673 */ 674 if( qtlive365 !== ''){ 675 qtlive365 = 'https://api.live365.com/station/'+qtlive365; 676 if(qtUseProxy){ 677 qtlive365 = proxyURL+'?qtproxycall='+window.btoa(qtlive365); 678 } 679 680 $.ajax({ 681 type: 'GET', 682 cache: false, 683 url: qtlive365, 684 async: true, 685 jsonpCallback: "parseMusic", 686 jsonp: false, 687 success: function(data) { 688 // console.log(data); 689 jsondata = data; 690 // console.log(json); 691 if('object' !== typeof( data )){ 692 data = JSON.parse(data); 693 } 694 if( data['current-track'].art ){ 695 var art = data['current-track'].art; 696 if( art != ''){ 697 callBack(art); 698 // console.log(art); 699 callBack = false; 700 } 701 } 702 fn.qtApplyTitle(data['current-track'].artist+' - '+data['current-track'].title, callBack); 703 }, 704 error: function(e){ 705 console.log(e); 706 } 707 }); 708 } 709 710 /** 711 * =================================================================== 712 * 713 * Text 714 * 715 * =================================================================== 716 */ 717 else if(qttextfeed !== ''){ 718 var tfeedurl,jsondata, title, proxyURL, mydata; 719 if(qtUseProxy){ 720 tfeedurl = $("#qtmplayer-radiofeed-proxyurl").data('proxyurl'); 721 mydata = { 722 "qtproxycall": window.btoa(qttextfeed), 723 }; 724 } else { 725 tfeedurl = qttextfeed; 726 } 727 $.ajax({ 728 type: 'GET', 729 cache: false, 730 url: tfeedurl, 731 async: true, 732 data: mydata, 733 dataType: "html", 734 success: function(data) { 735 fn.qtApplyTitle( data, callBack ); 736 }, 737 error: function(e){ 738 console.log(e); 739 } 740 }); 741 return; 742 } 743 /** 744 * =================================================================== 745 * 746 * Radionomy 747 * 748 * =================================================================== 749 */ 750 else if(qtradionomy !== '' ) { 751 $.ajax({ 752 type: 'GET', 753 url: qtradionomy, 754 async: true, 755 cache: false, 756 dataType: "xml", 757 success: function(data) { 758 fn.qtApplyTitle( $(data).find('artists').html()+ ' - ' + $(data).find('title').html() ); 759 }, 760 error: function(e){ 761 console.log(e); 762 } 763 }); 764 } 765 766 /** 767 * =================================================================== 768 * 769 * AirTime 770 * 771 * =================================================================== 772 */ 773 else if(qtairtime !== '' && qtairtime !== 'undefined' && qtairtime !== undefined && typeof(qtairtime) !== 'undefined'){ 774 var jsondata, title; 775 $.ajax({ 776 type: 'GET', 777 cache: false, 778 url: qtairtime,//proxyURL, 779 async: true, 780 data: { 781 "qtproxycall": window.btoa(qtairtime), 782 }, 783 jsonpCallback: "parseMusic", 784 jsonp: true,//jsonp: true, 785 // contentType: "application/json", 786 success: function(data) { 787 // console.log(data); 788 if(typeof(data) !== 'object'){ 789 data = JSON.parse(data); 790 } 791 title = data.tracks.current.name; 792 fn.qtApplyTitle(title); 793 }, 794 error: function(e) { 795 } 796 }); 797 } 798 799 /** 800 * =================================================================== 801 * 802 * Icecast 803 * 804 * =================================================================== 805 */ 806 else if(qticecasturl !== '' && typeof(qticecasturl) !== 'undefined') { 807 var feedurl = qticecasturl; 808 var source; 809 var title; 810 var songdata; 811 if(qtUseProxy){ 812 feedurl = proxyURL; 813 songdata = { 814 "qtproxycall": window.btoa(qticecasturl), 815 }; 816 } 817 // beta 818 fn.log('Radio feed - Icecast '+ qticecasturl); 819 // generally ok, not working for LN Soulr Icecast 820 // console.log( proxyURL+'?qtproxycall='+window.btoa(qticecasturl) ); 821 $.ajax({ 822 type: 'GET', 823 cache: false, 824 url: feedurl, 825 async: true, 826 jsonpCallback: "parseMusic", 827 jsonp: false,//jsonp: true, 828 // dataType: 'jsonp', // not working with some radios 829 data: songdata, 830 // contentType: "application/json", 831 success: function(json) { 832 fn.log('Ajax response'); 833 fn.log( json ); 834 835 // console.log(json); 836 if('object' !== typeof( json )){ 837 json = JSON.parse(json); 838 } 839 source = json.icestats.source; 840 if('undefined' === typeof(source)){ 841 return; 842 } 843 if(qticecastmountpoint){ 844 source = source[qticecastmountpoint]; 845 } 846 if(qticecastchannel){ 847 // console.log("set source to 0"); 848 source = source[qticecastchannel]; 849 } 850 // since PR.3.2.3 851 // If there is no channel and there is no title, channel must be 0 852 if(!qticecastchannel && 'undefined' === typeof(source.title)){ 853 source = source[0]; 854 }
855 title = source.title; 856 857 if( source.artist ){ 858 title = title +' - '+source.artist; 859 } 860 fn.qtApplyTitle(title, callBack); 861 },error: function(e) { 862 console.log(e); 863 fn.log('Ajax response'); 864 fn.log( e ); 865 } 866 }); 867 868 869 870 871 } 872 /** 873 * =================================================================== 874 * 875 * ShoutCast 876 * 877 * =================================================================== 878 */ 879 else if (qtradiofeedHost !== '' && qtradiofeedPort !== '' && typeof(qtradiofeedHost) !== 'undefined'){ 880 // to tide up 881 var feedData = { 882 shoutcast_host: qtradiofeedHost, 883 shoutcast_port: qtradiofeedPort, 884 shoutcast_protocol: qtradiofeedProtocol, 885 shoutcast_channel: theChannel 886 }; 887 var channel = feedData.shoutcast_channel || 1; 888 var protocol = 'http'; 889 if(feedData.shoutcast_port === '443' || feedData.shoutcast_protocol === 'https' ){ 890 protocol = 'https'; 891 } 892 var shoutcastUrl = protocol+'://'+feedData.shoutcast_host+':'+feedData.shoutcast_port+'/stats?sid='+channel+'&json=1'; 893 var feedurl = shoutcastUrl; 894 895 if(qtUseProxy){ 896 feedurl = proxyURL; 897 songdata = { 898 "qtproxycall": window.btoa(shoutcastUrl), 899 }; 900 } 901 902 /** 903 * @since PR.3.4.6 2021 02 27 added fallback 904 */ 905 try{ 906 907 $.ajax({ 908 type: 'GET', 909 cache: false, 910 url: feedurl, 911 async: true, 912 data: songdata, 913 dataType: $.qtmplayerRadioFeedObj.qtFeedData.dataType, 914 contentType: "application/json", 915 success: function(json) { 916 if('object' !== typeof( json )){ 917 json = JSON.parse(json); 918 } 919 fn.qtApplyTitle( json.songtitle, callBack); 920 },error: function(e) { 921 if($.qtmplayerRadioFeedObj.qtFeedData.dataType !== 'jsonp'){ 922 $.qtmplayerRadioFeedObj.qtFeedData.dataType = 'jsonp'; 923 $.qtmplayerRadioFeedObj.fn.newFeedReading(); 924 } 925 } 926 }); 927 } catch(e){ 928 dataType = 'jsonp'; 929 console.log(e); 930 } 931 932 return; 933 } 934 /** 935 * =================================================================== 936 * 937 * Radio.co 938 * 939 * =================================================================== 940 */ 941 else if (qtradiodotco !== '' && typeof(qtradiodotco) !== 'undefined'){ 942 var rUrl = 'https://public.radio.co/stations/'+qtradiodotco+'/status' 943 $.ajax({ 944 type: 'GET', 945 cache: false, 946 url: rUrl, 947 async: true, 948 contentType: "application/json", 949 success: function(data) { 950 if( data['current_track'] ){ 951 title = data['current_track']['title']; 952 fn.log( 'Radio.co artwork: '+ data['current_track']['artwork_url_large'] ); 953 if( data['current_track']['artwork_url_large'] && 'function' === typeof(callBack) ){ 954 var art = data['current_track']['artwork_url_large']; 955 if( art !== ''){ 956 callBack( art ); 957 callBack = false; 958 } 959 } 960 } else { 961 title = 'Song title currently unavailable - Please check your radio settings'; 962 } 963 fn.qtApplyTitle(title, callBack); 964 }, 965 error: function(e) { 966 } 967 }); 968 } 969 /** 970 * =================================================================== 971 * 972 * Radioking 973 * 974 * =================================================================== 975 */ 976 else if (fd.servertype == 'type-radioking' && qtradioking !== '' ){ 977 var rUrl = 'https://api.radioking.io/widget/radio/'+qtradioking+'/track/current'; 978 $.ajax({ 979 type: 'GET', 980 cache: false, 981 url: rUrl, 982 async: true, 983 contentType: "application/json", 984 success: function(data) { 985 title = data.artist+' - '+data.title; 986 987 if(data.cover && 'function' === typeof(callBack)){ 988 callBack(data.cover); 989 callBack = false;
990 } 991 fn.qtApplyTitle(title, callBack); 992 }, 993 error: function(e) { 994 console.log(e); 995 } 996 }); 997 } 998 /** 999 * =================================================================== 1000 * 1001 * Azuracast 1002 * 1003 * =================================================================== 1004 */ 1005 else if (fd.servertype == 'type-azuracast' && qtazuracast !== '' ){ 1006 var rUrl = ''; 1007 1008 qtazuracast = qtazuracast + '?rand='+timestamp; 1009 1010 $.ajax({ 1011 type: 'GET', 1012 cache: false, 1013 url: qtazuracast, 1014 async: true, 1015 contentType: "application/json", 1016 success: function(data) { 1017 if( 'undefined' === typeof( data.now_playing ) ){ 1018 data = data[0]; 1019 } 1020 author = data.now_playing.song.artist; 1021 title = data.now_playing.song.title; 1022 if('' !== author){ 1023 title = author+' - '+title; 1024 } 1025 if(data.now_playing.song.cover && 'function' === typeof(callBack)){ 1026 callBack(data.now_playing.song.cover); 1027 callBack = false; 1028 } 1029 if(data.now_playing.song.art && 'function' === typeof(callBack)){ 1030 // console.log(data.now_playing.song.art); 1031 callBack(data.now_playing.song.art); 1032 callBack = false; 1033 } 1034 1035 if(data.cover && 'function' === typeof(callBack)){ 1036 callBack(data.cover); 1037 callBack = false; 1038 } 1039 if(data.art && 'function' === typeof(callBack)){ 1040 callBack(data.art); 1041 callBack = false; 1042 } 1043 fn.qtApplyTitle(title, callBack); 1044 }, 1045 error: function(e) { 1046 console.log(e); 1047 1048 } 1049 }); 1050 } 1051 } 1052 return; 1053 }, 1054 feedInterval: null, 1055 stopFeed: function(){ 1056 var o = $.qtmplayerRadioFeedObj; 1057 if("undefined" !== typeof($.qtmplayerRadioFeedObj.fn.qtFeedInterval) ){ 1058 clearInterval($.qtmplayerRadioFeedObj.fn.qtFeedInterval); 1059 } 1060 }, 1061 pushFeed: function( data ){ 1062 1063 1064 var o = $.qtmplayerRadioFeedObj; 1065 o.qtFeedData = data; 1066 1067 o.fn.log('pushFeed = INITIALIZE'+$.now()); 1068 o.fn.log(data); 1069 1070 1071 o.fn.stopFeed(); 1072 o.fn.newFeedReading(); 1073 $.qtmplayerRadioFeedObj.qtFeedData.dataType = ''; 1074 $.qtmplayerRadioFeedObj.fn.qtFeedInterval = setInterval( 1075 function(){ 1076 o.fn.newFeedReading(); 1077 }, 1078 $.qtmplayerRadioFeedObj.timeInterval 1079 ); 1080 }, 1081 log:function(msg){ 1082 var c = $("#qtmPlayerDebugger"); 1083 if(c.length > 0){ 1084 c.append(msg+'<br>'); 1085 } 1086 } 1087 } 1088 1089 }; 1090 $(document).ready(function(){ 1091 $.qtmplayerRadioFeedObj.fn.qtApplyTitle(); 1092 }); 1093})(jQuery); 1094 1095 1096 1097 1098
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.