title: How to create a playlist with a single php file and multiple media files?
body: <p>well I'm trying to create a great playlist of music, only using a sigle php file.</p>
  
  <p>Right now, with this code I can stream a song from a single media file source:</p>
  
  <pre><code>&lt;?php
  
    // Try and open the remote stream
    if (!$stream = fopen('http://example.com/audio.mp3', 'r')) {
      // If opening failed, inform the client we have no content
      header('HTTP/1.1 500 Internal Server Error');
      exit('Unable to open remote stream');
    }
  
    // It's probably an idea to remove the execution time limit - on Windows hosts
    // this could result in the audio stream cutting off mid-flow
    set_time_limit(0);
  
    // Inform the client we will be sending it some MPEG audio
    header('Content-Type: audio/mpeg');
  
    // Send the data
    fpassthru($stream);
    // Thanks DaveRandom
  
  ?&gt;
  </code></pre>
  
  <p>So, the idea is almost simple: with a single php file, create a playlist. The php file streams the first song, and then inmediatly, play another one - previously set on the php file - and over and over again, with all of the sources in the php file.</p>
  
  <p>Thanks.</p>