无需下载即可在网页中播放flv和mkv格式的视频

时间:2016-03-01 10:04:49

标签: html mysql video

我正在开发考试门户网站,教师为学生上传视频教程。当学生点击教程而不下载时,我想播放视频。视频包含(.flv,.mkv,.mp4)格式 我提到互联网,但不能理解任何一个帮助与简单的例子。 我使用的是php和mysql

    <html><body><table cellpadding="0" cellspacing="0" border="0" class="table table-hover table-stripped" id="example">
        <thead>
            <tr style="background:lightblue">
                <td align="center">Department Name</td>
                <th  align="center">Video Tutorials</th>
                <th align="center">Action</th>  
            </tr>
        </thead>
        <?php
        $query=mysql_query("select * from video_uploads order by id desc");
        while($row=mysql_fetch_array($query)){
            $name=$row['file'];
            $dept=$row['dept_name'];
        ?>
        <tr>
        <td>&nbsp;<?php echo $dept;?>
        </td>
            <td>
            <iframe width="460" height="215" src="staff/video/<?php echo $name ;?>" allowfullscreen=""></iframe>
                &nbsp;
            </td>

        </tr>
        <?php }?>       </table></body></html>

上传视频代码在这里

    if(isset($_POST['submit'])){    
 $dept_name=$_POST['dept'];
  $name=$_FILES['file']['name'];
  $size=$_FILES['file']['size'];
  $type=$_FILES['file']['type'];
  $temp=$_FILES['file']['tmp_name'];

  move_uploaded_file($temp,"video/".$name);
  $sql="INSERT INTO video_uploads(dept_name,file,type,size) VALUES('$dept_name','$name','$type','$size')";
    if(executeQuery($sql))


    {
    echo "      <script>
    alert('successfully uploaded');
    window.location.href='videoupload.php?success';
    </script>";

    }
    else
    {
    ?>
    <script>
    alert('error while uploading file');
    window.location.href='videoupload.php?fail';
    </script>
    <?php
    }
   }  
   ?>

1 个答案:

答案 0 :(得分:1)

<html><body><table cellpadding="0" cellspacing="0" border="0" class="table table-hover table-stripped" id="example">
        <thead>
            <tr style="background:lightblue">
                <td align="center">Department Name</td>
                <th  align="center">Video Tutorials</th>
                <th align="center">Action</th>  
            </tr>
        </thead>
        <?php
        $query=mysql_query("select * from video_uploads order by id desc");
        while($row=mysql_fetch_array($query)){
            $name=$row['file'];
            $dept=$row['dept_name'];
        ?>
        <tr>
        <td>&nbsp;<?php echo $dept;?>
        </td>
            <td>

            <video width="460" height="215" >
                 <source src="staff/video/<?php echo $name ;?>" type="videp/mp4" >
            </video>

                &nbsp;
            </td>

        </tr>
        <?php }?>       </table></body></html>

如果您想播放flv或mkv视频,只需将“mp4”替换为“mkv”或您想要的任何视频格式。