【问题标题】:Any Video Player Not able to Seek Video by Using Temporary Video Source File任何视频播放器都无法使用临时视频源文件搜索视频
【发布时间】:2015-05-03 17:16:51
【问题描述】:

我不想下载我的视频。所以我使用这个脚本是为了避免用户下载视频并且它有效!

但我无法随时播放此视频。这仅适用于谷歌浏览器。

这就是我使用以下脚本的原因:

index.php:

ini_set('session.use_cookies',1);
session_start();
$vid=uniqid(); 
$_SESSION[$vid]='myVideo.mp4';
echo '<video autoplay="autoplay">'
    .'<source src="video.php?video='.$vid.' type="video/mp4">'
    .'</video>'; 

video.php:

ini_set('session.use_cookies',1);
session_start();
$file='myhiddenvideos/'.$_SESSION[$_GET['video']];
$_SESSION=array();
$params = session_get_cookie_params();
setcookie(session_name(),'', time()-42000,$params["path"],$params["domain"],
                                         $params["secure"], $params["httponly"]);
if(!file_exists($file) or $file==='' or !is_readable($file)){
  header('HTTP/1.1 404 File not found',true);
  exit;
  }
readfile($file);
exit;

现在这段代码的问题是,我无法在任何时候寻找我的视频或从栏的任何位置播放它!

现场演示:http://thehacktools.com/

【问题讨论】:

    标签: javascript php video


    【解决方案1】:

    这是因为您的视频文件是作为text/html 文件提供的,因此浏览器不知道如何处理该文件。 (好吧,Firefox 明白,Chrome 不明白。)

    您必须通过Content-Typeheader向浏览器指明视频的MIME type

    header('Content-Type: video/mp4');
    readfile($file);
    exit;
    

    【讨论】:

    • 很抱歉,即使在 fox 和 chrome 中这都不起作用!.. 视频正在播放.. 但无法从任何位置开始.. 如果不使用我的方法,则可以工作。 :( 使用我的视频保护方法,它正在制作视频直播……请帮助我 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-21
    • 1970-01-01
    相关资源
    最近更新 更多