2012-02-08 36 views
0

我正在寫一個簡單的小型上下文媒體平臺。它主要基於所謂的HTTP Pseudostreaming,我使用php腳本調解媒體文件。這用於檢查對文件的訪問,並用於鏈接到正確的目錄。在下面我的代碼的基本部分:如何使用調解a.k.a. HTTP-Pseudostreaming腳本的PHP調解SWF-Flashfile?

// [...] 

header("Content-type: " . $file_type); 
header("Content-length: " . $file_size); 
header("Content-Disposition: attachment; filename=" . $file_name); 
header("Expires: " . gmdate ("D, d M Y H:i:s", (time() + $_CFG['FILE_EXPIRE_TIME']))); 
header("Last-Modified: " . gmdate ("D, d M Y H:i:s", filemtime($file_path))); 

$file_handle = fopen($file_path, "r"); 
while (!feof($file_handle)) { 
     print(fread($file_handle, FILETRANSFER_BUFFER_SIZE)); 
} 
fclose($file_handle); 

// [...] 

目前我使用這個腳本中繼MP3,FLV,MP4,PDF和圖像格式。這工作很好。此外,我想添加Flash支持(瑞士法郎)。但是文件被傳輸。由服務器發送HTTP標頭似乎也沒關係:

HTTP/1.1 200 OK 
Date: Wed, 08 Feb 2012 08:49:16 GMT 
Server: Apache/2.2.9 (Debian) DAV/2 SVN/1.5.1 PHP/5.2.6-1+lenny9 with 
Suhosin-Patch mod_python/3.3.1 Python/2.5.2 mod_ssl/2.2.9 OpenSSL/0.9.8g 
mod_perl/2.0.4 Perl/v5.10.0 
X-Powered-By: PHP/5.2.6-1+lenny9 
Expires: Thu, 07 Feb 2013 08:49:16 
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0 
Pragma: no-cache 
Content-length: 28869 
Content-Disposition: attachment; filename=SWFTest1.swf 
Last-Modified: Tue, 07 Feb 2012 08:31:00 
Content-Type: application/x-shockwave-flash 

唯一的問題是:如果我想打從瀏覽器(獨立Browsertype)這個flash文件這是行不通的。 flasharea保持空白。如果我直接鏈接到相同的.swf文件,它的工作原理。如果我使用我的中繼腳本下載並在本地播放Flash文件:它可以工作。

我打電話DHTML/JavaScript的線路有:

<script type="text/javascript" src="swfobject.js"></script> 

<div style="margin: 5px;" id="flashcontent"></div>        
<script type="text/javascript"> 
    var s1 = new SWFObject("file.php?id=236&type=media", "flashfile", "480", "360", "7"); 
    s1.addVariable("width","480"); 
    s1.addVariable("height","360"); 
    s1.write("flashcontent"); 
</script>  

什麼想法?

+1

你得到任何錯誤信息 – mgraph 2012-02-08 11:05:58

+0

我會安裝http://www.charlesproxy.com/看看發生了什麼事情。 – 2012-02-08 11:09:40

+0

不,我沒有收到任何錯誤消息。我使用類似於CharlesProxy的東西,在那裏我找到了我發佈的標題。它正確地下載文件,但它不會播放。 – 2012-02-08 11:15:09

回答