在视频之间旋转

时间:2013-09-26 11:49:29

标签: php html video

所以我有一个初始代码,可以旋转30张完美运行的图像。我正在尝试调整代码以便在30个视频之间轮换,但无法使其工作,因为视频未在我的主页面中加载。我错过了一些我必须改变的东西吗?代码如下。感谢

主页

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

rotate.php

    <?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);
    }
}

?>

0 个答案:

没有答案