Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

php代码:

    $fp = @fopen($file, 'rb');

    // 获取文件大小
    $size   = filesize($file); // File size
    $length = $size;           // Content length
    // 开始读取的位置
    $start  = 0;               // Start byte
    // 文件结尾
    $end    = $size - 1;       // End byte

    // 设置缓存
    header("Cache-Control:max-age=604800");
    header('Etag: ' . md5($file));
    header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
    
    $length = $end - $start + 1; // Calculate new content length
    fseek($fp, $start);
    header('HTTP/1.1 206 Partial Content');

    // TODO 暂时写死测试
    header('Content-Type:video/mp4');
    header("Content-Range: bytes $start-$end/$size");
    header("Content-Length: $length");
    
    $buffer = 1024 * 8;
    while(!feof($fp) && ($p = ftell($fp)) <= $end) {
        if ($p + $buffer > $end) {
            $buffer = $end - $p + 1;
        }

        echo fread($fp, $buffer);
        // Free up memory.
        // Otherwise large files will trigger PHP's memory limit.
        flush();
    }

    fclose($fp);
    

前端是直接只用的video标签;

在PC浏览器上是可以正常播放的,但是去到微信上就无法播放了,这个要怎么解决?求指教!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
620 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...