I want to run video files in browser ...............

which format will be suitible for it..

and how to do this using HTML & PHP...

Need help.......

Recommended Answers

All 11 Replies

I want to run video files in browser ...............

which format will be suitible for it..

and how to do this using HTML & PHP...

Need help.......

Some one help me with some code...........

commented: This is not 24/7 support line for you only! -2

hi nil
checkout this code which will upload only avi,dat,mpg and wmv video files only create uplodedvideos in ur folder

if($_SERVER['REQUEST_METHOD']=='POST')
{
if($HTTP_POST_FILES["video"]["size"] >1) {	 // for  large image 1
			 $ext = substr($HTTP_POST_FILES['video']['name'],strpos($HTTP_POST_FILES['video']['name'],'.')+1);
			$ext_arr=array("avi","dat","mpg","wmv");
			//if (in_array($ext,$ext_arr)) { 			
				 $prlvideo=substr($HTTP_POST_FILES['video']['name'],0,strpos($HTTP_POST_FILES['video']['name'],'.'));
				$prlvideo.=time();
				 $prlvideo.=strstr($HTTP_POST_FILES['video']['name'],'.'); 	
				$prlvideo="uplodedvideos/".$prlvideo;			
				if(!move_uploaded_file($HTTP_POST_FILES['video']['tmp_name'],$prlvideo)) { $prlvideo=""; }
				chmod($prlvideo,0777); 
								
			} else {		
				$prlvideo="";
			}
			
			 $v = substr($HTTP_POST_FILES['video']['name'],strpos($HTTP_POST_FILES['video']['name'],'.')+1);
			 if($v=='avi' || $v=='dat' || $v=='mpg' || $v=='wmv')
			 {
			 
	  $qry2="INSERT INTO vdo_cat(`c_name`,`videos`,`parent_id`)VALUES ('".$_POST['txtsubcategory']."','".$prlvideo."','".$_POST['selcategory']."')";
			 $res2=mysql_query($qry2) or die(mysql_error()); if($res2==1)
				 {
				 	header("location:manage_videos.php?msg=ad");
				 }
				 }
				 else
			 {
			 $vmsg="You must upload only videos....";
			 
			 }
			
				}

hi nil
checkout this code which will upload only avi,dat,mpg and wmv video files only create uplodedvideos in ur folder

if($_SERVER['REQUEST_METHOD']=='POST')
{
if($HTTP_POST_FILES["video"]["size"] >1) {	 // for  large image 1
			 $ext = substr($HTTP_POST_FILES['video']['name'],strpos($HTTP_POST_FILES['video']['name'],'.')+1);
			$ext_arr=array("avi","dat","mpg","wmv");
			//if (in_array($ext,$ext_arr)) { 			
				 $prlvideo=substr($HTTP_POST_FILES['video']['name'],0,strpos($HTTP_POST_FILES['video']['name'],'.'));
				$prlvideo.=time();
				 $prlvideo.=strstr($HTTP_POST_FILES['video']['name'],'.'); 	
				$prlvideo="uplodedvideos/".$prlvideo;			
				if(!move_uploaded_file($HTTP_POST_FILES['video']['tmp_name'],$prlvideo)) { $prlvideo=""; }
				chmod($prlvideo,0777); 
								
			} else {		
				$prlvideo="";
			}
			
			 $v = substr($HTTP_POST_FILES['video']['name'],strpos($HTTP_POST_FILES['video']['name'],'.')+1);
			 if($v=='avi' || $v=='dat' || $v=='mpg' || $v=='wmv')
			 {
			 
	  $qry2="INSERT INTO vdo_cat(`c_name`,`videos`,`parent_id`)VALUES ('".$_POST['txtsubcategory']."','".$prlvideo."','".$_POST['selcategory']."')";
			 $res2=mysql_query($qry2) or die(mysql_error()); if($res2==1)
				 {
				 	header("location:manage_videos.php?msg=ad");
				 }
				 }
				 else
			 {
			 $vmsg="You must upload only videos....";
			 
			 }
			
				}

Thanx for ur attention...........But my problem is how to display uploaded videos in any browser using WM player

hi,
here is the code for displaying videos for the code above

<?	
include_once('functions.php');
include_once('conn.php');
if(!empty($_GET['pid']))
{
	 $pqry="SELECT * FROM vdo_cat where c_id=".$_GET['pid'];
	$pres=mysql_query($pqry) or die(mysql_error());
	$prow=mysql_fetch_array($pres);
	$len=strrpos($prow['videos'],'.');
	$vtype=substr($prow['videos'],$len+1,5);
	echo $vname=($prow['videos']);
	if(isset($vtype))
	{
?>
<html>
<link href="site.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5)">
<body>
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#83CBED">
  <tr>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center" valign="middle"><object id="MediaPlayer1" width="180" height="200"
classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
standby="Loading Microsoft® Windows® Media Player components..."
type="application/x-oleobject" align="middle">
<param name="FileName" value="video path/<?=$vname; ?>">
<param name="ShowStatusBar" value="True">
<param name="DefaultFrame" value="mainFrame">
<param name="autostart" value="false">
<embed type="application/x-mplayer2"
pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/"
src="../banjara_admin/videos/<?=$vname; ?>"
autostart="false"
align="middle"
width="176"
height="144"
defaultframe="rightFrame"
showstatusbar="true">
</embed>
</object>
<a href="YourFilesName.mpeg"><font size="2">Clickhere for standalone player</font></a>
<a href="http://www.microsoft.com/windows/windowsmedia/mp10/default.aspx">
<font size="1">Download Windows Media Player Here</font></a></p></td>
      </tr>
      <tr>
        <td></td><? } }?>
      </tr>
      <tr>
        <td align="center" valign="middle"><a href="#" class="orngsml" onClick="javascript:window.close();" ><strong>Close</strong></a></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>

when user clicks on play videos will play in a window in my program (see above... 'pid' )
it worked fine for me

hi,
here is the code for displaying videos for the code above

<?	
include_once('functions.php');
include_once('conn.php');
if(!empty($_GET['pid']))
{
	 $pqry="SELECT * FROM vdo_cat where c_id=".$_GET['pid'];
	$pres=mysql_query($pqry) or die(mysql_error());
	$prow=mysql_fetch_array($pres);
	$len=strrpos($prow['videos'],'.');
	$vtype=substr($prow['videos'],$len+1,5);
	echo $vname=($prow['videos']);
	if(isset($vtype))
	{
?>
<html>
<link href="site.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5)">
<body>
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#83CBED">
  <tr>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center" valign="middle"><object id="MediaPlayer1" width="180" height="200"
classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
standby="Loading Microsoft® Windows® Media Player components..."
type="application/x-oleobject" align="middle">
<param name="FileName" value="video path/<?=$vname; ?>">
<param name="ShowStatusBar" value="True">
<param name="DefaultFrame" value="mainFrame">
<param name="autostart" value="false">
<embed type="application/x-mplayer2"
pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/"
src="../banjara_admin/videos/<?=$vname; ?>"
autostart="false"
align="middle"
width="176"
height="144"
defaultframe="rightFrame"
showstatusbar="true">
</embed>
</object>
<a href="YourFilesName.mpeg"><font size="2">Clickhere for standalone player</font></a>
<a href="http://www.microsoft.com/windows/windowsmedia/mp10/default.aspx">
<font size="1">Download Windows Media Player Here</font></a></p></td>
      </tr>
      <tr>
        <td></td><? } }?>
      </tr>
      <tr>
        <td align="center" valign="middle"><a href="#" class="orngsml" onClick="javascript:window.close();" ><strong>Close</strong></a></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>

when user clicks on play videos will play in a window in my program (see above... 'pid' )
it worked fine for me

You have included function.php do this page compile without this file

yes it will,check my code if any errors let us know

Hi Praveen...

This is great....

I want some clarity about this video playing...

Can u send me the two php files with data base table....because the above two files are not matching with their column names...i am confusing....plz send me clearly with patiencs...

Thank u..

Why not just use FLV? its a lot simpler and will work in Firefox/Safari as well as IE
P.S. I know you can run WMP plugin in firefox but its an extra download you don't need (Not sure about Safari thoug)

yet another drop in media player

<?php ob_start("ob_gzhandler"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/TR/REC-html40">
<head>
<style>
.logo { background: transparent; color: #000000; text-align: right; top: auto; left: auto; bottom: 1px; right: 1px; position: fixed; }
</style>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript">
<!--//
function shrink(){
 document.getElementById("MediaPlayer1").style.width=384;
 document.getElementById("MediaPlayer1").style.height=300;
}
function enLarge(){
 document.getElementById("MediaPlayer1").style.width=480;
 document.getElementById("MediaPlayer1").style.height=402;
}
 //-->
</script>
<title>video</title>
</head><body><a name='top'></a>
<p class='logo'>
<button onclick="enLarge()">large</button>
<button onclick="shrink()">small</button>
<A HREF="http://www.microsoft.com/windows/windowsmedia/player/download/"><IMG ALT="Get Windows Media Player" SRC="http://www.microsoft.com/windows/windowsmedia/images/logos/getwm/mp11_88x31_static.gif" WIDTH="88" HEIGHT="31" BORDER="0"></A><br>
<OBJECT ID="MediaPlayer1" width=384 height=300 classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">
<PARAM NAME="fileName" VALUE="">
<PARAM NAME="showControls" VALUE="true">
<PARAM NAME="PlayCount" VALUE="0">
<PARAM NAME="animationatStart" VALUE="true">
<PARAM NAME="transparentatStart" VALUE="true">
<PARAM NAME="autoStart" VALUE="true">
<EMBED type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" SRC="" name="MediaPlayer1" width=360 height=260 AutoStart=true></EMBED></object></p>
<div style='float:left; text-align:left;'>
<?php $p = split('/', $_SERVER['SCRIPT_FILENAME']);
$script_name = $p[count($p)-1];
$path = str_replace($script_name, '', $_SERVER['SCRIPT_FILENAME']);
$dir_handle = @opendir($path) or die("Unable to open $path");
Function get_Extension($m_FileName){
$path_parts = pathinfo($m_FileName);
if ($path_parts["extension"]) {
 $m_Extension = strtolower($path_parts["extension"]);
 return(strtoupper($m_Extension));
 }
else { return "unknown file"; }
 }
 function check_image($filename){
 $temp=strtoupper(get_Extension($filename));
 if(($temp=="WMV")||($temp=="ASF"))
 return (true);
 else
 return (false);
 }
 Function get_Files($path) {
 if ($handle = opendir($path)) {	
  while (false !== ($file = readdir($handle))) { 
  if(!is_dir($file) && substr($file,O,1) != ".") { 
$m_Files[]=$file; }
}
 closedir($handle); 
}
 if(sizeof($m_Files)>1)
 asort($m_Files);
 return $m_Files;
 }
 $files=get_Files($path); 
 $filter_files=array_filter($files,"check_image");
 $maxnr=sizeof($filter_files)-1;
 sort($filter_files);
for ($i=0;$i<sizeof($filter_files);$i++){
echo "<a onclick=\"MediaPlayer1.SRC='$filter_files[$i]';MediaPlayer1.fileName='$filter_files[$i]';\">";
echo substr($filter_files[$i], 0, strlen($filter_files[$i])-4);
echo "</a><br>";
 }
closedir($dir_handle); ?>
</table></body></html>
<?php ob_flush(); ?>

You have included function.php do this page compile without this file

Hi,

Can, you provide me some running example. It will be great helpful for me. My mail id is <snipped>.

Thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.