1var currentSongId = ''; 2var advStatus = 'stop'; 3$(document).ready(function () { 4 var player = $('#player')[0]; 5 var container = $('.player'); 6 var body = $('body'); 7 var mainPlayer = $('#main-player'); 8 9 10 function resumeStream() { 11 player.play(); 12 } 13 14 function get(url) { 15 return $.ajax({ 16 url: url, 17 xhrFields: { 18 withCredentials: true 19 }, 20 crossDomain: true, 21 type: 'GET', 22 dataType: 'xml' 23 }) 24 } 25 26 27 28 29 function playStream(stream) { 30 // if (advStatus === 'play') { 31 // player.play(); 32 // return; 33 // } 34 35 // playAdv().then(() => { 36 player.src = stream; 37 player.load(); 38 player.play(); 39 // }).catch(function () { 40 // player.src = stream; 41 // player.load(); 42 // player.play(); 43 // }); 44 45 } 46 47 function pauseStream() { 48 player.pause(); 49 } 50 51 container.on('click', '.bitrate .play-action', function () { 52 var src = $(this).data('stream'); 53 $('.bitrate .play-action', container).removeClass('active'); 54 $(this).addClass('active'); 55 var t = $('#main-player'); 56 t.removeClass('pause'); 57 t.addClass('play'); 58 t.data('stream', src); 59 playStream(src); 60 return false; 61 }); 62 63 function swapHtml(el1, el2) { 64 var tmp = el1.html(); 65 el1.html(el2.html()); 66 el2.html(tmp); 67 } 68 69 70 container.on('click', '.play-action.pause', function (e) { 71 e.preventDefault(); 72 var radio = $(this).data('radio'); 73 var target_li = $('#radio-' + radio.id); 74 var target_button = $($('.play-action', target_li)[0]); 75 var current_li = $('li.current', container); 76 var current_button = $($('.player-main .play-action', current_li)[0]); 77 var current_radio = current_button.data('radio'); 78 79 80 if (current_radio.id == radio.id) { 81 return; 82 } 83 84 current_li.attr('id', 'radio-' + radio.id); 85 target_li.attr('id', 'radio-' + current_radio.id); 86 87 //console.log(radio); 88 //console.log(current_radio); 89 90 current_button.data('radio', radio); 91 current_button.data('stream', radio.defaultStream.stream); 92 target_button.data('radio', current_radio); 93 //$('.play-action', target_li).data('stream', current_li.defaultStream.stream); 94 95 swapHtml($('.al-name', current_li), $('.al-name', target_li)); 96 swapHtml($('.al-track', current_li), $('.al-track', target_li)); 97 swapHtml($('.artist-pic', current_li), $('.artist-pic', target_li)); 98 $('.status-id', target_li).html(current_radio.title); 99 100 $('.bitrate-container', current_li).html(''); 101 102 $.each(radio.streams, function (i, stream) { 103 var a = $('<a>'); 104 a.data('bitrate', stream.bitrate); 105 a.data('stream', stream.stream); 106 a.html(stream.bitrate); 107 a.addClass('play-action'); 108 if (stream.bitrate == radio.defaultStream.bitrate) { 109 a.addClass('active'); 110 } 111 $('.bitrate-container', current_li).append(a); 112 }); 113 114 115 playStream(radio.defaultStream.stream); 116 $('.play-action.play').removeClass('play').addClass('pause'); 117 current_button.removeClass('pause'); 118 current_button.addClass('play'); 119 return false; 120 }); 121 122 123 container.on('click', '.play-action.play', function () { 124 125 }); 126 127 128 body.on('click', '.play-action.pause', function () { 129 $('.play-action.play').removeClass('play').addClass('pause'); 130 var src = $(this).data('stream'); 131 $(this).removeClass('pause'); 132 $(this).addClass('play'); 133 var songId = $(this).data('song-id'); 134 135 if (songId && currentSongId == songId) { 136 resumeStream(); 137 } else { 138 currentSongId = songId; 139 playStream(src); 140 } 141 return false; 142 }); 143 144 body.on('click', '.play-action.play', function () { 145 pauseStream(); 146 $(this).removeClass('play'); 147 $(this).addClass('pause'); 148 return false;
149 }); 150 151 $('.volume-adjust-body > div').slider({ 152 orientation: "vertical", 153 range: "min", 154 min: 0, 155 max: 100, 156 value: $('#player')[0].volume * 100, 157 slide: function (event, ui) { 158 $('#player')[0].volume = ui.value / 100; 159 } 160 }); 161 162 currentSong(); 163 164}); 165 166function currentSong() { 167 $.ajax({ 168 url: 'https://api.svoyoradio.by/lastsong', /* ÐÑда оÑпÑавиÑÑ Ð·Ð°Ð¿ÑÐ¾Ñ */ 169 method: 'get', /* ÐеÑод запÑоÑа (post или get) */ 170 dataType: 'json', /* Тип даннÑÑ Ð² оÑвеÑе (xml, json, script, html). */ 171 data: {text: 'ТекÑÑ'}, /* ÐаннÑе пеÑедаваемÑе в маÑÑиве */ 172 success: function(data){ /* ÑÑнкÑÐ¸Ñ ÐºÐ¾ÑоÑÐ°Ñ Ð±ÑÐ´ÐµÑ Ð²Ñполнена поÑле ÑÑпеÑного запÑоÑа. */ 173 //console.log(data); /* РпеÑеменной data ÑодеÑжиÑÑÑ Ð¾ÑÐ²ÐµÑ Ð¾Ñ index.php. */ 174 175 if(data.label === 'music') { 176 document.querySelector('.al-name').innerHTML = `${data.artist}` 177 document.querySelector('.al-track').innerHTML = `${data.title}` 178 } else { 179 document.querySelector('.al-name').innerHTML = `Ð¡Ð²Ð¾Ñ Ñадио` 180 document.querySelector('.al-track').innerHTML = `` 181 } 182 183 } 184 }); 185 setTimeout(currentSong, 5000); 186}; 187 188 189
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.