欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

php 网页播放器用来播放在线视频的代码(自动判断并选择视频文件类型)

程序员文章站 2023-10-31 21:30:58
在web开发中经常会碰到一些简单的视频播放功能,但现在的视频格式不同,并且可以动态增加,所以我们就必须把视频保存到数据哦,好了下面我们来看我写的段简单的 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>
<?
}
?>