RSS

Stream MP3 using PHP – m3u

11 Apr

M3U is a computer file format that stores multimedia playlists.

<?php

function m3u_stream($dir) {

$mp3=””;
$siteurl=”http://www.domain.com/mp3/&#8221;;

$h1 = opendir($dir);

while ($file = readdir($h1))
{

if ($file == ‘.’ || $file == ‘..’) continue;
$mp3.=$siteurl.basename($dir).”/”.$file.”\r\n”;

}

closedir($h1);

return $mp3;

}

$folder = “svnlabs”;

file_put_contents($folder.”.m3u”, m3u_stream($_SERVER[“DOCUMENT_ROOT”].”/mp3/”.$folder.”/”));

?>

Here “svnlabs” is a folder where all mp3 files exists… this program will create svnlabs.m3u playlist file using php script.

svnlabs.m3u file contents all mp3 links with domain “http://www.domain.com/mp3/&#8221;

svnlabs.m3u
………………



……………………

Now http://www.domain.com/mp3/svnlabs.m3u can be used for streaming mp3 from http://www.domain.com

Advertisements
 
1 Comment

Posted by on April 11, 2010 in Fedora, Linux, php, Tips, Tricks, Web Services

 

Tags: , , , ,

One response to “Stream MP3 using PHP – m3u

  1. blog.svnlabs.com

    November 12, 2010 at 10:23 pm

    I doubt it.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: