首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >flowplayer、php和javascript:隐藏流名称

flowplayer、php和javascript:隐藏流名称
EN

Stack Overflow用户
提问于 2013-02-03 21:31:24
回答 1查看 2.4K关注 0票数 0

所以我使用flowplayer来播放rtmp流,但是当前流的web视图显示流的"key“或url。

当这是真的,其他用户将能够“接管”流,这是我们不想要的。所以我需要能够在网页代码中隐藏"key“或url。我不想要任何身份验证,因为许多通用RTMP streamer程序在流式传输时不支持。

在你说之前,我已经看过http://flash.flowplayer.org/demos/plugins/streaming/secure-streaming.html了,但是我不能让它与RTMP流一起工作,只有一个固定的.flv流…

以下是我的代码btw:

代码语言:javascript
复制
<a  
style="display:block;width:960px;height:540px;margin:10px auto"
id="stream">
</a>
<script type="text/javascript">
flowplayer("stream", "http://xxx.net/live/files/flowplayer-3.2.15.swf",
{
clip: {
url: 'stream name url key goes here',
live: true,
provider: 'rtmp'
},
plugins: {
rtmp: {
url: 'http://xxx.net/live/files/flowplayer.rtmp-3.2.11.swf',
netConnectionUrl: 'rtmp://xxx.net/live'
}
}
}
);
</script>
EN

回答 1

Stack Overflow用户

发布于 2013-09-06 11:49:47

您需要使用php文件(或其他替代文件)动态提供URL,它必须是服务器端代码,如下所示

代码语言:javascript
复制
<?php
  $hash = $_GET['h'];
  $streamname = $_GET['v'];
  $timestamp = $_GET['t'];
  $current = time();
  $token = 'sn983pjcnhupclavsnda';
  $checkhash = md5($token . '/' . $streamname . $timestamp);

  if (($current - $timestamp) <= 2 && ($checkhash == $hash)) {
  $fsize = filesize($streamname);
   header('Content-Disposition: attachment; filename="' . $streamname . '"');
  if (strrchr($streamname, '.') == '.mp4') {
   header('Content-Type: video/mp4');
   } else {
  header('Content-Type: video/x-flv');
  }
  header('Content-Length: ' . $fsize);
  session_cache_limiter('nocache');
  header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
  header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre check=0');
  header('Pragma: no-cache');
  $file = fopen($streamname, 'rb');
  print(fread($file, $fsize));
  fclose($file);
  exit;
  } else {
  header('Location: /url/');
  }

?>

请注意,$streamname是从JS的url部分拉出的

代码语言:javascript
复制
 <script type="text/javascript">
 // <![CDATA[
 window.onload = function () {
  $f("player", "flowplayer-3.2.16.swf", {
   plugins: {
    secure: {
      url: "flowplayer.securestreaming-3.2.8.swf",
      timestampUrl: "sectimestamp.php"
    }
  },
  clip: {
    url: "trailer.flv",
    urlResolvers: "secure",
    scaling: "fit",
    onStart: function (clip) {
      document.getElementById("info").innerHTML = clip.baseUrl + "/" + clip.url;
        }
       }
     });
     };
     // ]]>
     </script>

Flow Player会混淆你的url,所以如果有人试图从flash player中提取源码,它将是domain.com/md5hashtimestamp/md5hashtoken/md5hashstreamname/trailer.flv,当他们查看源码时,他们只能看到文件名,但是域名等是通过php文件提供服务的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14673009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档