【问题标题】:How to mediate a SWF-Flashfile using a PHP mediating a.k.a. HTTP-Pseudostreaming script?如何使用 PHP 中介 a.k.a. HTTP-Pseudostreaming 脚本来中介 SWF-Flashfile?
【发布时间】:2012-02-08 10:55:42
【问题描述】:

我正在编写一个简单的小型上下文媒体平台。它主要基于所谓的 HTTP 伪流,我使用 php 脚本来调解媒体文件。这用于检查对文件的访问,并用于链接到正确的目录。以下是我的代码的基本部分:

// [...]

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 支持 (swf)。但是文件被传输。服务端发送的 HTTP Header 好像也没问题:

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

唯一的问题是:如果我想从浏览器(独立于浏览器类型)播放这个 flash 文件,它不起作用。闪现区域保持空白。如果我直接链接到同一个 .swf 文件,它就可以工作。如果我使用我的中继脚本下载并在本地播放 flashfile:它可以工作。

我的调用 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>     

有什么想法吗?

【问题讨论】:

  • 我会安装charlesproxy.com 看看发生了什么。
  • 不,我没有收到任何错误消息。我使用类似于 CharlesProxy 的东西,我从中获取我发布的标题。它可以正确下载文件,但根本无法播放。
  • @nemcija 当您将 file.php?id=236&amp;type=media 替换为 SWFTest1.swf 时会起作用
  • 正如我所写:“如果我直接链接到同一个 .swf 文件,它就可以工作。”

标签: php html flash http mediator


【解决方案1】:

Content-Disposition: attachment; filename=SWFTest1.swf 是导致问题的标头。从 Flash 10.0.2 开始,出于安全原因,它的存在阻止了 SWF 的加载。

参考:http://www.adobe.com/devnet/flashplayer/articles/fplayer10_security_changes.html#head32

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-03
    • 1970-01-01
    • 2014-03-25
    • 2016-12-26
    • 1970-01-01
    • 2017-11-02
    相关资源
    最近更新 更多