我想将视频上传到服务器,然后使用PHP使用某些播放器(如youtube)在网页上显示。
我的客户问:“视频不得超过2分钟,并且采用Quicktime,WMV,Mp4或FLV格式。”
是否有任何开源脚本可以帮助我上传具有客户端要求的视频,然后是一个播放该视频的开源播放器?
请帮忙!
谢谢
这是我最喜欢的解决方案:http://flowplayer.org/
它可以控制视频很多:它使用javascript设置和嵌入式Flash视频播放器。
编辑:如果你寻找好的上传者,试试http://code.google.com/p/swfupload/
它可以执行多次上传和文件类型检查。
首先,您必须创建指向您要播放的视频的链接(我在单独的页面上创建了我的链接[index.html])。然后点击链接,它将打开页面(play.php)。我假设index.html正在显示数据库中视频的链接,然后播放的其余脚本由play.php处理。见下面的代码:
的index.html
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<style type="text/css">
tr:nth-child(odd) {
background-color: #f2f2f2
}
</style>
</head>
<body>
<center>
<table width="53%" border="1">
<tr>
<td width="8%">S/NO</td>
<td width="92%">NAME OF VIDEO FILE</td>
</tr>
<tr>
<td align="center">1</td>
<td><a href="play.php?url=Funny_Naija_Video_Animation.mp4&pic=ng.png">Funny Nigeria Video Animation</a></td>
</tr>
<tr>
<td align="center">2</td>
<td><a href="play.php?url=WildGeese.mp4&pic=wg.png">Joan Armatrading-
Flight of the Wild Geese - MP4</a></td>
</tr>
</table>
</center>
</body>
</html>
play.php
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Fluid Width Video</title>
<style>
* { margin: 0; padding: 0; }
body {
font: 16px/1.4 Georgia, Serif;
width: 50%;
margin: 80px auto;
background: url(images/bglines.png);
}
h1 { font-weight: normal; font-size: 42px; }
h1, p, pre, video, h2, figure, h3, ol { margin: 0 0 15px 0; }
h2 { margin-top: 80px; }
h1 { margin-bottom: 40px; }
li { margin: 0 0 5px 20px; }
article { background: white; padding: 10%; }
pre { display: block; padding: 10px; background: #eee; overflow-x: auto; font: 12px Monaco, MonoSpace; }
img { max-width: 100%; }
.videoWrapper {
position: relative;
padding-bottom: 56.25%;
padding-top: 25px;
height: 0;
}
.videoWrapper iframe,
.videoWrapper object,
.videoWrapper embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
video {
width: 100% !important;
height: auto !important;
}
figure { display: block; background: #eee; padding: 10px; }
figcaption { display: block; text-align: center; margin: 10px 0; font-style: italic; font-size: 14px; orphans: 2; }
</style>
</head>
<body>
<?
if(isset($_GET['url'])){
$vid = "movies/".$_GET['url'];
$pos = "movies/".$_GET['pic'];
if($pos == "movies/ng.png"){
$cap = "Animation - Funny Play Station 3 Nigerin video clip";
}
if($pos == "movies/wg.png"){
$cap = "Jordan Armsterdam - The flight of the Wild Geese";
}
?>
<figure>
<video src="<?php echo $vid;?>" controls poster="<?php echo $pos;?>"></video>
<figcaption><?php echo $cap; ?></figcaption>
</figure>
<?php }else{ echo "You must be a paid Student in order to watch video tutorial!"; }?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
var $allVideos = $(".js-resize"),
$fluidEl = $("figure");
$allVideos.each(function() {
$(this)
// jQuery .data does not work on object/embed elements
.attr('data-aspectRatio', this.height / this.width)
.removeAttr('height')
.removeAttr('width');
});
$(window).resize(function() {
var newWidth = $fluidEl.width();
$allVideos.each(function() {
var $el = $(this);
$el
.width(newWidth)
.height(newWidth * $el.attr('data-aspectRatio'));
});
}).resize();
</script>
</body>
</html>