You are here: fpassthru and mp3 player « PHP Programming Language « IT news, forums, messages
fpassthru and mp3 player

Posted by alex bazan on 10/22/39 11:26

I've got musicplayer http://musicplayer.sourceforge.net/ pointing to a
php file which dumps with fpassthru and appropiate headers an mp3 file.

If i point the mp3 directly i have no problems, but with the php script
songs stop playing when after a while (always at the same length)...

I've tried removing headers but then the file does not play at all. With
other players i've experience the same cut at the same length. If i
don't use the player (ie, dumping the file directly to the browser), i
can hear all the song without problems.

It seems as if the player only gets ok the first X bytes that got
transfered.

I want to have the files out of the apache root path, that's why i use
the php script to dump the files.

This is the file "player.php" which shows the player and dumps the file:

<?php

session_start();

function filesend($filename,$contenttype,$path,$dispo="inline") {
header("Pragma: ");
header("Cache-Control: ");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Content-Disposition: $dispo; filename=$filename");
header("Content-Description: $filename");
header("Content-Type: $contenttype");
header("Content-Length: ".filesize($path));
header("Connection: close");

if ($fp=fopen($path,"rb")) {
fpassthru($fp);
fclose($fp);
}
}

if (isset($_GET["path"])) {
$_SESSION["path"]=$_GET["path"];
?>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="400" height="15" id="xspf_player" align="middle">
<param name="allowScriptAccess" value="sameDomain"/>
<param name="movie" value="/js/xspf/xspf_player_slim.swf"/>
<param name="quality" value="high"/>
<param name="bgcolor" value="#e6e6e6"/>
<embed
src="/js/xspf/xspf_player_slim.swf?song_url=player.php&song_title=<?=basename($_SESSION["path"])?>"
quality="high" bgcolor="#e6e6e6" width="400" height="15"
name="xspf_player" align="middle" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<?php
} else {
filesend(basename($_SESSION["path"]),"audio/mpeg",$_SESSION["path"]);
}
?>



Any ideas??

Thanks.
alex.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация