php 网页播放器用来播放在线视频的代码(自动判断并选择视频文件类型)
更新时间:2010年06月03日 23:58:52 作者:
其实这里的php 视频播放代码基本上常见的视频格式都支持,用正则匹配文件扩展名,并根据文件扩展名的不同调用相应的在线播放器代码。
在web开发中经常会碰到一些简单的视频播放功能,但现在的视频格式不同,并且可以动态增加,所以我们就必须把视频保存到数据哦,好了下面我们来看我写的段简单的 php视频网页播放器代码吧。
<?PHP
include './admin/connect.php';
@extract($db->get_one("select * from movieinfo where id='".$_GET['id']."'"));
$db->query("update movieinfo set playnum=playnum+1 where id='".$_GET['id']."' ");
//控制下载
$url2="admin/";//存放软件的路径
if($localaddress)
{
$newname=$localaddress;
$movieurl=$url2.$newname;
}
?>
<html>
<head>
<title><?=$title?>-在线播放 jb51.net</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<?php
//MediaPlayer播放
if (eregi(".mid$",$movieurl) || eregi(".avi$",$movieurl) || eregi(".asf$",$movieurl) ||eregi(".asx$",$movieurl) || eregi(".wmv$",$movieurl) || eregi(".wma$",$movieurl))
{
?>
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="application/x-oleobject" width=350 height=280 align="middle" standby="Loading Microsoft?Windows?Media Player components..." id="MediaPlayer1">
<param name="transparentAtStart" value="True">
<param name="transparentAtStop" value="True">
<param name="AnimationAtStart" value="Ture">
<param name="AutoStart" value="True">
<param name="AutoRewind" value="true">
<param name="DisplaySize" value="0">
<param name="AutoSize" value="false">
<param name="ShowDisplay" value="false">
<param name="ShowStatusBar" value="ture">
<param name="ShowControls" value="ture">
<param name="FileName" value="<?=$movieurl?>">
<param name="Volume" value="0">
<embed src="" width="350" height=280 autostart="True" align="middle" transparentatstart="True" transparentatstop="True" animationatstart="Ture" autorewind="true" displaysize="0" autosize="false" showdisplay="False" showstatusbar="-1" showcontrols="ture" filename="<?=$movieurl?>" volume="0">
</embed>
</object>
<?php
}elseif(eregi(".ra$",$movieurl)|| eregi(".mp3$",$movieurl) || eregi(".rm$",$movieurl) || eregi(".ram$",$movieurl) ){
//RealPlayer播放的
?>
<object ID="video" CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" HEIGHT="280" WIDTH="350" align="center">
<param name="_ExtentX" value="9260">
<param name="_ExtentY" value="6350">
<param name="AUTOSTART" value="-1">
<param name="SHUFFLE" value="0">
<param name="PREFETCH" value="0">
<param name="NOLABELS" value="0">
<param name="SRC" value="<?=$movieurl?>">
<param name="CONTROLS" value="ImageWindow">
<param name="CONSOLE" value="Clip1">
<param name="LOOP" value="0">
<param name="NUMLOOP" value="0">
<param name="CENTER" value="0">
<param name="MAINTAINASPECT" value="0">
<param name="BACKGROUNDCOLOR" value="#000000"><embed SRC="4.rpm" type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1" CONTROLS="ImageWindow" HEIGHT="240" WIDTH="352" AUTOSTART="false">
</object><br>
<object ID="video" CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" HEIGHT="40" WIDTH="350" align="center">
<param name="_ExtentX" value="9260">
<param name="_ExtentY" value="1058">
<param name="AUTOSTART" value="-1">
<param name="SHUFFLE" value="0">
<param name="PREFETCH" value="0">
<param name="NOLABELS" value="0">
<param name="CONTROLS" value="ControlPanel,StatusBar">
<param name="CONSOLE" value="Clip1">
<param name="LOOP" value="0">
<param name="NUMLOOP" value="0">
<param name="CENTER" value="0">
<param name="MAINTAINASPECT" value="0">
<param name="BACKGROUNDCOLOR" value="#000000"><embed type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1" CONTROLS="ControlPanel,StatusBar" HEIGHT="60" WIDTH="275" AUTOSTART="false">
</object>
<?php
}elseif(eregi(".swf$",$movieurl)) {
//flashplayer播放的
?>
<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="350" height="280">
<param name="movie" value="<?=$movieurl?>">
<param name="quality" value="High">
<embed src="<?=$movieurl?>" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="350" height="280">
</object>
<?
}
?>
复制代码 代码如下:
<?PHP
include './admin/connect.php';
@extract($db->get_one("select * from movieinfo where id='".$_GET['id']."'"));
$db->query("update movieinfo set playnum=playnum+1 where id='".$_GET['id']."' ");
//控制下载
$url2="admin/";//存放软件的路径
if($localaddress)
{
$newname=$localaddress;
$movieurl=$url2.$newname;
}
?>
<html>
<head>
<title><?=$title?>-在线播放 jb51.net</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<?php
//MediaPlayer播放
if (eregi(".mid$",$movieurl) || eregi(".avi$",$movieurl) || eregi(".asf$",$movieurl) ||eregi(".asx$",$movieurl) || eregi(".wmv$",$movieurl) || eregi(".wma$",$movieurl))
{
?>
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="application/x-oleobject" width=350 height=280 align="middle" standby="Loading Microsoft?Windows?Media Player components..." id="MediaPlayer1">
<param name="transparentAtStart" value="True">
<param name="transparentAtStop" value="True">
<param name="AnimationAtStart" value="Ture">
<param name="AutoStart" value="True">
<param name="AutoRewind" value="true">
<param name="DisplaySize" value="0">
<param name="AutoSize" value="false">
<param name="ShowDisplay" value="false">
<param name="ShowStatusBar" value="ture">
<param name="ShowControls" value="ture">
<param name="FileName" value="<?=$movieurl?>">
<param name="Volume" value="0">
<embed src="" width="350" height=280 autostart="True" align="middle" transparentatstart="True" transparentatstop="True" animationatstart="Ture" autorewind="true" displaysize="0" autosize="false" showdisplay="False" showstatusbar="-1" showcontrols="ture" filename="<?=$movieurl?>" volume="0">
</embed>
</object>
<?php
}elseif(eregi(".ra$",$movieurl)|| eregi(".mp3$",$movieurl) || eregi(".rm$",$movieurl) || eregi(".ram$",$movieurl) ){
//RealPlayer播放的
?>
<object ID="video" CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" HEIGHT="280" WIDTH="350" align="center">
<param name="_ExtentX" value="9260">
<param name="_ExtentY" value="6350">
<param name="AUTOSTART" value="-1">
<param name="SHUFFLE" value="0">
<param name="PREFETCH" value="0">
<param name="NOLABELS" value="0">
<param name="SRC" value="<?=$movieurl?>">
<param name="CONTROLS" value="ImageWindow">
<param name="CONSOLE" value="Clip1">
<param name="LOOP" value="0">
<param name="NUMLOOP" value="0">
<param name="CENTER" value="0">
<param name="MAINTAINASPECT" value="0">
<param name="BACKGROUNDCOLOR" value="#000000"><embed SRC="4.rpm" type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1" CONTROLS="ImageWindow" HEIGHT="240" WIDTH="352" AUTOSTART="false">
</object><br>
<object ID="video" CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" HEIGHT="40" WIDTH="350" align="center">
<param name="_ExtentX" value="9260">
<param name="_ExtentY" value="1058">
<param name="AUTOSTART" value="-1">
<param name="SHUFFLE" value="0">
<param name="PREFETCH" value="0">
<param name="NOLABELS" value="0">
<param name="CONTROLS" value="ControlPanel,StatusBar">
<param name="CONSOLE" value="Clip1">
<param name="LOOP" value="0">
<param name="NUMLOOP" value="0">
<param name="CENTER" value="0">
<param name="MAINTAINASPECT" value="0">
<param name="BACKGROUNDCOLOR" value="#000000"><embed type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1" CONTROLS="ControlPanel,StatusBar" HEIGHT="60" WIDTH="275" AUTOSTART="false">
</object>
<?php
}elseif(eregi(".swf$",$movieurl)) {
//flashplayer播放的
?>
<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="350" height="280">
<param name="movie" value="<?=$movieurl?>">
<param name="quality" value="High">
<embed src="<?=$movieurl?>" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="350" height="280">
</object>
<?
}
?>
相关文章
php foreach 使用&(与运算符)引用赋值要注意的问题
foreach 通过在 $value 之前加上 & 很容易就能修改数组的单元,在 foreach 使用引用时要注意了。也可以在处理完后立即断开引用关系,后面就不会有上述情况了。2010-02-02实测在class的function中include的文件中非php的global全局环境
正如标题所言经测试的结果为:在class中include后,被include文件变量域已经变成func中了,非全局.但是可以通过global提升,感兴趣的朋友可以参考下哈,希望对大家有所帮助2013-07-07Thinkphp结合ajaxFileUpload实现异步图片传输示例
这篇文章主要给大家介绍了利用Thinkphp结合ajaxFileUpload实现异步图片传输的方法,文中给出了详细的示例代码,对大家具有一定的参考价值,需要的朋友们下面来一起看看吧。2017-03-03
最新评论