Ped@ntilva Posted January 16, 2007 at 01:01 AM Report #76527 Posted January 16, 2007 at 01:01 AM Boas, estou a ter uns problemas. Eu estou a criar um script que faz o stream de vídeos .wmv mas estou com um problema, No meu pc o stream só funciona até um determinado ponto do vídeo, no servidor nem funciona. Aqui fica o code: <?php if(isset($_GET['id']) ){ $id = $_GET['id']; if ($id > 0){ $file = "$id.wmv"; if ($stream = fopen($file, 'r')) { header('Content-type: video/x-ms-wmv'); while (!feof($stream)) echo stream_get_line($stream, 100); fclose($stream); }else print "Ocorreu um erro."; } else print "Ocorreu um erro."; }else print "Ocorreu um erro."; ?> Alguma sugestão??? Cumps, Pedantilva
marinheiro Posted January 16, 2007 at 02:43 AM Report #76533 Posted January 16, 2007 at 02:43 AM esse é também um problema com que me estou a debater... há 10 tipos de pessoas: as que sabem binário e as que não sabem... todas as nossas vidas não passam de release candidates... com o aperfeiçoamento, um dia chegaremos à versão final..
karva Posted January 16, 2007 at 09:44 AM Report #76534 Posted January 16, 2007 at 09:44 AM <?php if(isset($_GET['id']) ){ $id = $_GET['id']; $file = "$id.wmv"; if ($stream = fopen($file, 'r')) { header('Content-type: video/x-ms-wmv'); while (!feof($stream)) echo stream_get_line($stream, 100); fclose($stream); }else print "Ocorreu um erro."; }else print "Ocorreu um erro."; ?> Assim ele abre o ficheiro de video no WMP. Isto no IE7, no FF 2.0 nem abre... É isso que querias? Proud LEIC-A@IST student!
Ped@ntilva Posted January 16, 2007 at 11:31 AM Author Report #76543 Posted January 16, 2007 at 11:31 AM Não, o que quero é que noutra página faço um embed do video e ia buscar o video através do ficheiro PHP. Para que o pessoal não fique a saber o endereço físico do vídeo e poder escondê-lo. <object id="MediaPlayer" width="352" height="360" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"> <param name="filename" value="media/?id=4"> <param name="Showcontrols" value="True"> <param name="autoStart" value="True"> <embed width="352" height="360" enablefullscreencontrols="1" windowless="1" enablecontextmenu="0" displaysize="0" autosize="0" allowchangedisplaysize="0" transparentatstart="0" animationatstart="0" showstatusbar="1" showdisplay="0" showcontrols="1" name="player" src="media/?id=4" type="video/x-ms-wmv"/></embed> </object>
Ped@ntilva Posted January 16, 2007 at 01:53 PM Author Report #76564 Posted January 16, 2007 at 01:53 PM Bem, já consegui. EDIT: No meu pc não dava o vídeo todo devido ao timeout e no servidor não reconhecia a função stream_get_line() Não sei se será a melhor forma, mas aqui está: if(isset($_GET['id']) ){ $id = $_GET['id']; if ($id > 0){ $file = "$id.wmv"; if ($stream = fopen($file, 'r')) { header('Content-type: video/x-ms-wmv'); while(!feof($stream)) echo fgets($stream,100); fclose($stream); }else print "Ocorreu um erro."; } else print "Ocorreu um erro."; }else print "Ocorreu um erro."; Aceito sugestões para melhorar... Cumps, Pedantilva
djthyrax Posted January 16, 2007 at 06:50 PM Report #76632 Posted January 16, 2007 at 06:50 PM if(isset($_GET['id']) && $_GET['id'] > 0 ){ header('Content-type: video/x-ms-wmv'); readfile("./".$_GET['id'].".wmv"); }else{ header("500 Internal Error"); echo "A msg do erro ftw."; } 😛 Não peças ajuda por PM! A tua dúvida vai ter menos atenção do que se for postada na secção correcta do fórum!
Ped@ntilva Posted January 17, 2007 at 01:26 PM Author Report #76846 Posted January 17, 2007 at 01:26 PM Gostei da função readfile(); Eis o produto final: $fileid=0; if (isset($_GET['id'])) $fileid=intval($_GET['id']); $filename= "$fileid.wmv"; $fileurl = "media/$filename"; $filesize= filesize ($fileurl); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: video/x-ms-wmv"); header("Content-Disposition: attachment; filename=\"".basename($filename)."\";"); header("Content-Transfer-Encoding: base64"); header("Content-Length: ".$filesize); @readfile("$fileurl") or die("File not found.");
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now