开发者

Playing AVI with PHP readfile()

开发者 https://www.devze.com 2023-03-29 03:13 出处:网络
I have embeded player inHTML: <OBJECT id=WindowsMediaPlayer1 width=320 height=264 hspace=5 vspace=5 classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6 border=\"5\" align=\"middle\" >

I have embeded player in HTML:

<OBJECT id=WindowsMediaPlayer1 width=320 height=264 hspace=5
vspace=5 classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6 border="5" align="middle" >
<param name="URL" value="http://www.my.domain/stream开发者_如何学C.php">

<EMBED type='application/x-mplayer2'
pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'
bgcolor='darkblue' showcontrols="true" showtracker='-1'
showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="320" height="264"
src="http://www.my.domain/stream.php" autostart="0" designtimesp='5311'>
</EMBED>
</OBJECT>

stream.php

<?php
$path='/path/to/file/my.avi';
header('Content-type: video/x-msvideo');
header('Content-Length: '.filesize($path));
readfile($path);
?>

video is playing when: src="http://www.my.domain/my.avi video is not playing when: src="http://www.my.domain/stream.php (no pictures)

P.S. mp4,flv,mov works

can you help me?

lubo


I think it's all in the headers... found a tutorial online.. http://www.devshed.com/c/a/PHP/Video-Streaming-PHP-Script-Tutorial/3/

In the tutorial that guy used:

header('Content-type: video/mpeg');    
header('Content-Length: '.filesize($path)); // provide file size    
header("Expires: -1");    
header("Cache-Control: no-store, no-cache, must-revalidate");    
header("Cache-Control: post-check=0, pre-check=0", false);    
readfile($path);


try setting the location header instead:

$path='/path/to/file/my.avi';
header("location: $path");


I suspect you are sending the wrong content-type header. It is generally necessary to get that header right, if you want the client to know what type of content it is.

You can verify this by using Fiddler and comparing the headers from when the file is accessed directly, vs. when access via your script.


simple solution... Make a mp4, mov or flv file, use that within your website

0

精彩评论

暂无评论...
验证码 换一张
取 消