DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   How to include FLV videos in php (http://www.daniweb.com/forums/thread118213.html)

saji.ka Apr 9th, 2008 6:45 am
How to include FLV videos in php
 
Dear All,

I am new to PHP. I would like to include video (Flash Videos) in the website using PHP. Can u please help by giving the code.

Saji

Daedal Apr 9th, 2008 12:00 pm
Re: How to include FLV videos in php
 
Quote:

Originally Posted by saji.ka (Post 580679)
Dear All,

I am new to PHP. I would like to include video (Flash Videos) in the website using PHP. Can u please help by giving the code.

Saji



Here is code from a previous project of mine. Use as much or as little as you want. The function I have included really only uses 5 fields:
videoID
status
title
caption
embed_code

MySQL Videos Table
DROP TABLE IF EXISTS `videos`;
CREATE TABLE `videos` (
  `videoID` mediumint(8) unsigned NOT NULL auto_increment,
  `status` enum('Active','Disabled') NOT NULL default 'Active',
  `title` varchar(35) default NULL,
  `caption` text,
  `category` varchar(35) default NULL,
  `filename` varchar(35) default NULL,
  `embed_code` text,
  `video_date` date NOT NULL default '0000-00-00',
  PRIMARY KEY  (`videoID`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

--
-- Dumping data for table `videos`
--

INSERT INTO `videos` (`videoID`, `status`, `title`, `caption`, `category`, `filename`, `embed_code`, `video_date`) VALUES (1, 'Active', 'Lonely Angel', 'Kid Theodore''s Lonely Angel music video', 'www.kidtheodore.com', NULL, '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/l5os6oII8Hk"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/l5os6oII8Hk" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>', '2007-10-25')

PHP function to call the information from the database.
You would need to connect to your database first.

function getVideo($vid) {
//$vid = a videoID in the table videos
        $query = "SELECT * FROM videos WHERE status = 'Active' AND videoID = '$vid'";
        $result = mysql_query($query);
            if (mysql_num_rows($result) > 0) {               
                $row = mysql_fetch_array( $result );
                        $output .= "
                        <h2>$row[title]</h2>
                        $row[embed_code]<br>
                        $row[caption]
                        ";
          } else {
          $output = "No video was found at this time.<br> Please check back soon.<br>";
          }

                       
return $output;
} //usage //echo getVideo($vid);


saji.ka Apr 10th, 2008 1:13 am
Re: How to include FLV videos in php
 
Thank you very much . Is working and solved my problem.

Saji

saji.ka Apr 10th, 2008 2:21 am
Re: How to include FLV videos in php
 
Quote:

Originally Posted by saji.ka (Post 581234)
Thank you very much . Is working and solved my problem.

Saji



The code worked fine with youtube video. When I replaced with my video it is a FLV file and its name is pv160308.flv, it is not working.

What I did ..

replaced the value="http://www.youtube.com/v/l5os6oII8Hk" and
src=" http://www.youtube.com/v/l5os6oII8Hk"
with local
value="pv160308.flv" and
src= "pv160308.flv".

When executed . no display is coming.

Could u pl. help

Saji

Daedal Apr 22nd, 2008 7:19 pm
Re: How to include FLV videos in php
 
Quote:

Originally Posted by saji.ka (Post 581267)
The code worked fine with youtube video. When I replaced with my video it is a FLV file and its name is pv160308.flv, it is not working.

What I did ..

replaced the value="http://www.youtube.com/v/l5os6oII8Hk" and
src=" http://www.youtube.com/v/l5os6oII8Hk"
with local
value="pv160308.flv" and
src= "pv160308.flv".

When executed . no display is coming.

Could u pl. help

Saji



I guess I misunderstood the question. You need to create an Adobe Flash FLV player... which would be a SWF file that has controls (play pause rewind) You could create this file to use a FLASHVAR to name the FLV file that you want to load in.
Ex:

src= "flvplayer.swf?video=pv160308.flv"

There would be a variable in your flash file called 'video' that it would load onto the scene.

ryan_vietnow Apr 22nd, 2008 7:22 pm
Re: How to include FLV videos in php
 
you can try JW flash player.It's free and easy to use.


All times are GMT -4. The time now is 10:57 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC