2016-03-01 60 views
1

我正在开发考试门户网站,其中教师上传学生的视频教程。我想播放视频,当学生点击教程没有下载.video包括(.flv,.mkv,.mp4)格式 我介绍了互联网,但不能理解请任何一个简单的例子帮助。 我使用PHP和MySQL在没有下载的情况下在网页中播放flv和mkv格式的视频

<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 
    } 
    } 
    ?> 
+0

Ther在mkv或flv的视频标签中不支持。只有MP4和ogg和webm。因此,文件必须转换..文件仍然下载,它只是浏览器自动为你做。 – szatmary

回答

0
<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 “或任何你想要的视频格式。

+0

如果我将它替换为flv或mkv,它将直接下载。只有MP4播放器正在播放 –

+0

我已经测试了很多播放视频的方法,但所有选项都变得太旧了,所以它们不能正常工作,您可以做的一件事是,您应该在另一个浏览器上再次尝试此方法或更新现有浏览器。 –

+0

这个答案是不正确的。视频标签无法播放flv或mkv。 – szatmary

相关问题