Jump to content
php.lv forumi

m3u playlist problēma...


vienmer-iesacejs

Recommended Posts

Tātad ir uztaisīts pavisam vienkāršs php skripts, kas uzģenerē .m3u playlist failu izmantojot datubāzi,

bet lieta tāda, ka man viņš visu saliek vienā rindiņā.

 

#EXTM3U #EXTINF: 1, nosaukums http://manaadrese.com/fails

 

Kā lai ieliek atstarpes, lai izskatītos šādi:

 

#EXTM3U

 

#EXTINF: 1, nosaukums

http:/manaadrese.com/fails

 

Rekur daļa no mana skripta...


$sql="SELECT * FROM tracks";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
 {
  //generating playlist
  $livePlaylist .= '#EXTM3U';
  $livePlaylist .= '#EXTINF: '.$row['nr'].', '.$row['name'].'';
  $livePlaylist .= ''.$url.'';
 }


header("Content-type: application/m3u;\n");
header("Content-Transfer-Encoding: binary");
$outname=$q.'.m3u';
header("Content-Disposition: attachment; filename=\"$outname\";\n\n");
echo $livePlaylist;

Link to comment
Share on other sites

while($row = mysql_fetch_array($result))
 {
  //generating playlist
  $livePlaylist .= '#EXTM3U\n\n';
  $livePlaylist .= '#EXTINF: '.$row['nr'].', '.$row['name'].'\n';
  $livePlaylist .= ''.$url.'';
 }

 

\n - vajadzētu pārnest nākamo rakstāmo rindiņu jaunā rindā.

Edited by Sasa
Link to comment
Share on other sites

@Sasa - nē, šitie \n te laikam nedarbosies.

 

 

@vienmer-iesacejs - A tu paņem un truli ar ENTER'u saregulē kā vajag.

Tipa:

while($row = mysql_fetch_array($result))
 {
  //generating playlist
  $livePlaylist .= '#EXTM3U

  ';
  $livePlaylist .= '#EXTINF: '.$row['nr'].', '.$row['name'].'
  ';
  $livePlaylist .= ''.$url.'

  ';
 }

Link to comment
Share on other sites

$sql="SELECT * FROM tracks";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
 {
  //generating playlist
  $livePlaylist .= '#EXTM3U'.PHP_EOL;
  $livePlaylist .= '#EXTINF: '.$row['nr'].', '.$row['name'].PHP_EOL;
  $livePlaylist .= $url.PHP_EOL;
 }


header("Content-type: application/m3u;\n");
header("Content-Transfer-Encoding: binary");
$outname=$q.'.m3u';
header("Content-Disposition: attachment; filename=\"$outname\";\n\n");
echo $livePlaylist;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...