Hello, the radio code of the radio player, which loads the data on the current track from a file using php, which takes data from a text file.

But the player is located on a large number of sites, which often causes a large load.

Is it possible to somehow optimize the work and reduce the load?

Player Code js:

<script type="text/javascript"> var player_default = "GTI Radio"; var player_loading = "Идёт загрузка..."; var player_ready = false; var player_stream_default = 1; var player_streams = [{ title: "96", mp3: "http://radio.globaltranceinvasion.com:8000/radiolow" }, { title: "128", mp3: "http://radio.globaltranceinvasion.com:8000/radiomid" }, { title: "256", mp3: "http://radio.globaltranceinvasion.com:8000/radiohi" }, { title: "320", mp3: "http://radio.globaltranceinvasion.com:8000/radio320" }]; $(document).ready(function () { function getStreamSong() { $.ajax({ url: "http://player.gtiradio.ru/count.php", cache: false, success: function (html) { $(".song").html(html); } }); } function setRadioPlay() { getStreamSong(); radioSongUpdate = setInterval(getStreamSong, 20000); } function setRadioStop() { clearInterval(radioSongUpdate); } $("#jquery_jplayer_1").jPlayer({ ready: function (event) { player_ready = true; $(this).jPlayer('setMedia', player_streams[player_stream_default]); }, pause: function () { $(this).jPlayer('clearMedia'); $('#player .song').text(player_default); setRadioStop(); }, error: function (event) { if (player_ready && event.jPlayer.error.type === $.jPlayer.error.URL_NOT_SET) { $('#player .song').html(player_loading); $(this).jPlayer('setMedia', player_streams[player_stream_default]).jPlayer('play'); setRadioPlay(); } else { $('#player .song').text(player_default); setRadioStop(); } }, swfPath: "jsplayer", supplied: "mp3", solution: "html, flash", preload: "none", wmode: "window", keyEnabled: true }); $('#player .streams a').bind('click', function () { var key = $(this).attr('data-stream'); player_stream_default = key; $('#player .song').html(player_loading); $('#player .streams a').removeClass('active'); $(this).addClass('active'); $('#jquery_jplayer_1').jPlayer('clearMedia'); $('#player .song').html(player_loading); $('#jquery_jplayer_1').jPlayer('setMedia', player_streams[player_stream_default]).jPlayer('play'); setRadioPlay(); return false; }); var mPlayer = $("#jquery_jplayer_1"), options = { volumechange: function (event) { if (event.jPlayer.options.muted) { myControl.volume.slider("value", 0); } else { myControl.volume.slider("value", event.jPlayer.options.volume); } }, cssSelectorAncestor: "#jp_container_1" } myControl = { volume: $(options.cssSelectorAncestor + " .jp-volume-slider") }; $('.jp-gui ul li').hover( function () { $(this).addClass('u-state-hover'); }, function () { $(this).removeClass('u-state-hover'); } ); myControl.volume.slider({ animate: "fast", max: 1, range: "min", step: 0.01, value: $.jPlayer.prototype.options.volume, superslide: function (event, ui) { mPlayer.jPlayer("option", "muted", false); mPlayer.jPlayer("option", "volume", ui.value); } }); $('#player a.jp-play').bind('click', function () { $('#player .song').html(player_loading); setRadioPlay(); return false; }); }); </script> 

Php code:

 <?php $str=file_get_contents('http://gtiradio.ru/player/nowplaying.txt'); echo $str; ?> 
  • one
    cached to static file. - zb '
  • how to implement it *? - Alexander Sizintsev
  • one
    And how are all sites linked to the source of the tracks? What exactly slows down: the server tracks or js? What makes you think that js slows down? I would even say with confidence that this player is not slow. Because In this js, the config for the player is simply described. What is your server? - Victor Halauko
  • Yes, of course, not js. there is nothing to hurt, just the frame is inserted player on other sites. - Alexander Sizintsev
  • one
    Why do you keep track names in the file? Mysql will work hundreds of times faster with a large number of tracks !!!! I am sure that you have tens of thousands of songs there, and php will search there for the right composition for a very long time! As I understand it, you are importing a file with tracks to your site. So put all the records in the database. Any track will be searched for thousandths of a second on a normal server. - Victor Halauko

0