duanjiaren8188 2016-11-09 19:14
浏览 69

卷曲视频搜索栏不工作

I have the code in which I used the curl for getting video address and video run as well but code doesnt allow me to forwarding the video

My view code is like :

<video id="videos" width='300px' height='200px' controls>
    <source src="video.php" type='video/mp4'/>
</video>

Here I can play the above video but seekbar(forwarding the video) is not working properly

I am very glad if anyone can help me ?

Thanks in advance

  • 写回答

1条回答 默认 最新

  • dongmei2957 2016-11-14 07:15
    关注

    Your PHP script serving the video needs to set the HTTP Accept-Ranges header and needs to honor the HTTP_RANGE that is requested. That should be enough.

    You haven't posted any of the PHP code for video.php (or image.php which you included in your example), so I can't be 100% sure this will do exactly what you are looking for.

    This is a decent example of what I think you are trying to do: http://codesamplez.com/programming/php-html5-video-streaming-tutorial

    This is the important part:

    $this->start = 0;
    $this->size  = filesize($this->path);
    $this->end   = $this->size - 1;
    header("Accept-Ranges: 0-".$this->end);
    
    if (isset($_SERVER['HTTP_RANGE'])) {
    
        $c_start = $this->start;
        $c_end = $this->end;
    
        list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
        if (strpos($range, ',') !== false) {
            header('HTTP/1.1 416 Requested Range Not Satisfiable');
            header("Content-Range: bytes $this->start-$this->end/$this->size");
            exit;
        }
        if ($range == '-') {
            $c_start = $this->size - substr($range, 1);
        }else{
            $range = explode('-', $range);
            $c_start = $range[0];
    
            $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $c_end;
        }
        $c_end = ($c_end > $this->end) ? $this->end : $c_end;
        if ($c_start > $c_end || $c_start > $this->size - 1 || $c_end >= $this->size) {
            header('HTTP/1.1 416 Requested Range Not Satisfiable');
            header("Content-Range: bytes $this->start-$this->end/$this->size");
            exit;
        }
        $this->start = $c_start;
        $this->end = $c_end;
        $length = $this->end - $this->start + 1;
        fseek($this->stream, $this->start);
        header('HTTP/1.1 206 Partial Content');
        header("Content-Length: ".$length);
        header("Content-Range: bytes $this->start-$this->end/".$this->size);
    }
    else
    {
        header("Content-Length: ".$this->size);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里