• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

PHP Improve my website radio

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,492
Solutions
27
Reaction score
858
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I wanted to open this request to see if someone knows how to help me. I made a quick radio, very simple, that reproduce songs saved in a folder of UniformServer. I take the opportunity to share it with the community, anyone who wants to use just install in any www/.php file.

The thing I need is, once a song ends, I would like to automatically reproduce the next. Can someone help me with that?

radio_example.png

At the moment I know that has to be something like
PHP:
nuevo_audio.addEventListener('ended',¿skip function here?)

Here is the whole script:

PHP:
<table border="0" cellspacing="1" cellpadding="4" width="100%">
  <tr bgcolor="#505050">
  <td class="white"><b><?php echo $config['site_title'] ?> | Radio FM<b></td>
  </tr>
  <td>
<center><p><strong><span style="color: Chocolate;">We bring you the best music to make your hours of play more enjoyable.</span></strong><p></p> If you leave the current window the played song will stop, we suggest you to open new tabs on navigator so as not to stop the music player.<p></p><script>
function cambiarTrack(track) {
   var path =  track.getAttribute("path")
   viejo_audio = document.getElementById("reproductor")
   audio_padre = viejo_audio.parentNode
   audio_padre.removeChild(viejo_audio)
   nuevo_audio = document.createElement("audio")
   nuevo_audio.setAttribute("id","reproductor")
   nuevo_audio.setAttribute("controls", "controls")
  // nuevo_audio.setAttribute("autoplay", "autoplay")
   source = document.createElement("source")
   source.setAttribute("src", path)
   source.setAttribute("type", "audio/mpeg")
   source.setAttribute("id", "reproductorSource")
   nuevo_audio.appendChild(source)
   audio_padre.appendChild(nuevo_audio)}
function cargarReproductor() {
         var select = document.getElementById("selectTrack")
         var path = select.options[0].getAttribute("path")
   nuevo_audio = document.createElement("audio")
   nuevo_audio.setAttribute("id","reproductor")
   nuevo_audio.setAttribute("controls", "controls")
   source = document.createElement("source")
   source.setAttribute("src", path)
   source.setAttribute("type", "audio/mpeg")
   source.setAttribute("id", "reproductorSource")
   nuevo_audio.appendChild(source)
   padre = document.getElementById("reproductorBox")
   padre.appendChild(nuevo_audio)
}
</script>
<p></p>
<div id="reproductorBox"></div>
<p></p>
<select id = "selectTrack" multiple onchange="cambiarTrack(this.options[this.selectedIndex]);">
<option path="../music/solia-bad-bunny-yhlqmdlg.mp3">Solia - Bad Bunny</option>
<option path="../music/mantoi-movimiento-original-desencadenate.mp3">Desencadenate - Mantoi</option>
<option path="../music/drefquila-me-entiendes-video-oficial.mp3">Me Entiendes - DrefQuila</option>
<option path="../music/pablo-chill-e-vibras-official-video.mp3">Vibras - Pablo Chill-E</option>
<option path="../music/SUBONE NACOREREOS CON JONAS SANCHE (2009) HUMO EN EL SALON.mp3">Humo en el Salon - Jonas Sanche</option>
<option path="../music/dr-dre-featuring-snoop-dogg-the-next-episode.mp3">Next Episode - Snoop Dogg</option>
<option path="../music/the-pharcyde-on-the-dl.mp3">On the DL - The Pharcyde</option>
<option path="../music/funky-child.mp3">Funky Child - Lords of the Underground</option>
<option path="../music/12-chystemc-i-love-you-a-lo-vio-con-movimiento-original-letra.mp3">I love you a lo vio - Chyste Mc</option>
<option path="../music/aerstame-destinos-cruzados-con-movimiento-original.mp3">Destinos Cruzados - M.O</option>
<option path="../music/amor-de-los-cuero-suazo-baby-sean-yev-zion-video-oficial.mp3">Amor de los Cuero - Zion</option>
<option path="../music/gran-rah-amor-con-furia-ft-flowyn.mp3">Amor con Furia - Gran Rah</option>
<option path="../music/rels-b-mary-jane-letra.mp3">Mary Jane - Rels B</option>
<option path="../music/tbt.mp3">Tbt - Easy Kid X Young Cister</option>
<option path="../music/mntp-feat-pikette23.mp3">Mntp - Baby J & MLSHBTS</option>
<option path="../music/all-about-u-ft-nate-dogg-snoop-dogg-fatal-yani-hadati.mp3">All About You - 2pac</option>
<option path="../music/mente-sabia-cru-con-salvaje-decibel-821-ocho-veintiuno-con-letra.mp3">Ocho Veintiuno - Mente Sabia Craw</option>
<option path="../music/wiz-khalifa-the-plan-feat-juicy-j-official-audio.mp3">The Plan - Wiz Khalifa</option>
<option path="../music/todo-por-nada.mp3">Todo por Nada - Shamanes</option>
<option path="../music/soldados-del-ghetto.mp3">Soldados del Ghetto - M.O</option>
<option path="../music/mantoi-sonambulo-con-letra.mp3">Soñambulo - Mantoi</option>
<option path="../music/artifacts-stbb375.mp3">Artifacts_stbb375 · Eli Filosov</option>
<option path="../music/post-malone-swae-lee-sunflower-sub-espanol.mp3">Sunflower - Post Malone</option>
<option path="../music/rudebwoy-feat-joey-bada.mp3">Rudebwoy - CJ Fly</option>
</select>
<script>cargarReproductor();</script><p></p>
  </td>
</table>

Thanks in advance!
Regards
 
Last edited:
Last edited:
Solution
Back
Top