我试图将视频文件上传到数据库并与videoJS播放器一起播放。 一切正常,但视频不起作用,它显示加载图标,并在那里停止,视频不播放。有没有人能发现什么是错的?我正在使用视频js www.videojs.com
这是index.php文件:
<html>
<head>
<title>Video Upload System</title>
<link rel='stylesheet' href='style.css' />
</head>
<body>
<?php
include 'connect.php';
?>
<div id='box'>
<form method="post" enctype='multipart/form-data'>
<?php
if(isset($_FILES['video'])){
$name = $_FILES['video']['name'];
$type = explode('.', $name);
$type = end($type);
$size = $_FILES['video']['size'];
$random_name = rand();
$tmp = $_FILES['video']['tmp_name'];
if($type != 'mp4' && $type != 'MP4' && $type != 'avi'){
$message = "Video Format Not Supported";
}else{
move_uploaded_file($tmp, 'videos/'.$random_name.'.'.$type);
mysqli_query($connect, "INSERT INTO cinema VALUES ('','$name','$random_name.$type')");
$message = "Successfully Uploaded";
}
echo "$message <br/><br/>";
}
?>
Select Video: <br/>
<input type='file' name='video' />
<br><br>
<input type='submit' value='Upload Video'/>
</form>
</div>
<div id='box'>
<?php
$query = mysqli_query($connect, "SELECT id, name, url FROM cinema");
while ($run = mysqli_fetch_array($query)){
$video_id = $run['id'];
$video_name = $run['name'];
$video_url = $run['url'];
?>
<a href="view.php?video=<?php echo $video_url; ?>">
<div id='url'>
<?php echo $video_name; ?>
</div>
</a>
<?php
}
?>
</div>
</body>
</html>
这是view.php文件:
<!doctype html>
<html lang="en">
<head>
<title>Video Upload System</title>
<link rel='stylesheet' href='style.css' />
<link href="http://vjs.zencdn.net/4.2/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.2/video.js"></script>
</head>
<body>
<?php
include 'connect.php';
?>
<div id='box'>
<?php
$video = $_GET['video'];
?>
<video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="auto" width="640" height="264"
poster="http://video-js.zencoder.com/oceans-clip.png"
data-setup='{"example_option":true}'>
<source src="<?php echo $video; ?>" type="video/mp4">
</video>
</div>
</body>
</html>
答案 0 :(得分:0)
您可以在此处下载最新的videojs(zip)播放器:http://www.videojs.com/
解压缩zip文件并使用demo.html,您可能需要构建autoplay = yes,或类似的东西。
答案 1 :(得分:0)
<html>
<head>
<link href="http://vjs.zencdn.net/4.11/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.11/video.js"></script>
</head>
<body>
<body>
<?php
if(isset($_FILES['video'])){
$name = $_FILES['video']['name'];
$type = explode('.', $name);
$type = end($type);
$size = $_FILES['video']['size'];
$random_name = rand();
$tmp = $_FILES['video']['tmp_name'];
if($type != 'mp4' && $type != 'MP4' && $type != 'avi'){
$message = "Video Format Not Supported";
}else{
move_uploaded_file($tmp, 'videos/'.$random_name.'.'.$type);
mysqli_query($connect, "INSERT INTO cinema VALUES ('','$name','$random_name.$type')");
$message = "Successfully Uploaded";
}
echo "$message <br/><br/>";
}
?>
<div id='box'>
<form method="post" enctype='multipart/form-data'>
Select Video: <br/>
<input type='file' name='video' />
<br><br>
<input type='submit' value='Upload Video'/>
</form>
<video id="MY_VIDEO_1" class="video-js vjs-default-skin" controls
preload="auto" width="640" height="264" poster="MY_VIDEO_POSTER.jpg"
data-setup="{}">
<source src="MY_VIDEO.mp4" type='video/mp4'>
<source src="MY_VIDEO.webm" type='video/webm'>
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video>
</body>
</html>