Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在视频之间轮换_Php_Html_Video - Fatal编程技术网

Php 在视频之间轮换

Php 在视频之间轮换,php,html,video,Php,Html,Video,因此,我有一个初始代码,在30个图像之间旋转,效果很好。我正在尝试调整代码,使其在30个视频之间轮换,但由于视频未加载到我的主页中,因此无法正常工作。我是否错过了一些我必须改变的东西?代码如下。谢谢 主页 $key = rand(1,30); <video width="320" height="240" controls autoplay> <source src="rotate.php?num=<?php echo $key; ?> $key=ran

因此,我有一个初始代码,在30个图像之间旋转,效果很好。我正在尝试调整代码,使其在30个视频之间轮换,但由于视频未加载到我的主页中,因此无法正常工作。我是否错过了一些我必须改变的东西?代码如下。谢谢

主页

$key = rand(1,30); 
<video width="320" height="240" controls autoplay>
    <source src="rotate.php?num=<?php echo $key; ?>
$key=rand(1,30);

请解释一下“让它工作”是什么意思。我的意思是它不会加载视频。如果我直接把实际的视频源放进去的话,它是可以工作的,但是这种视频的轮换不起作用,给这个问题添加了更多的描述
    <?php
    $folder = './videos';
    $extList = array();
    $extList['mp4'] = 'video/mp4';

$img = null;

if (substr($folder,-1) != '/') {
    $folder = $folder.'/';
}
$imageNumber = 3;

if(isset($_GET['num'])){
    $imageNumber = $_GET['num'];
}
if (isset($_GET['img'])) {
    $imageInfo = pathinfo($_GET['img']);
    if (
        isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
        file_exists( $folder.$imageInfo['basename'] )
    ) {
        $img = $folder.$imageInfo['basename'];
    }
} else {
    $fileList = array();
    $handle = opendir($folder);
    while ( false !== ( $file = readdir($handle) ) ) {
        $file_info = pathinfo($file);
        if (
            isset( $extList[ strtolower( $file_info['extension'] ) ] )
        ) {
            $fileList[] = $file;
        }
    }
    closedir($handle);

    if (count($fileList) > 0) {

        $img = $folder.$fileList[$imageNumber];
    }
}

if ($img!=null) {
    $imageInfo = pathinfo($img);
    $contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
    header ($contentType);
    readfile($img);
} else {
    if ( function_exists('imagecreate') ) {
        header ("Content-type: video/mp4");
        $im = @imagecreate (100, 100)
            or die ("Cannot initialize new GD image stream");
        $background_color = imagecolorallocate ($im, 255, 255, 255);
        $text_color = imagecolorallocate ($im, 0,0,0);
        imagestring ($im, 2, 5, 5,  "IMAGE ERROR", $text_color);
        imagepng ($im);
        imagedestroy($im);
    }
}

?>