Page 1 of 4
Making a Video Player.
Posted: Wed Feb 01, 2006 5:06 pm
by nickman013
I would like to make a very simple video player.
I have a lot of videos I want to include in this page.
I think I would need to set up a array of all the videos?
And then
Code: Select all
<embed src=<? echo $array[number] ?> other attributes>
I am not sure.
Basically what I want to do is this.
I have a video page, with alot of videos. I want the videos to just be played from one page.
For example. If the links are
Code: Select all
<a href=/playvideo?videoname=myvideo>Play My Video!</a>
Then this will open up the playvideo page and play myvideo.
Do you get what I mean.
I was thinking of how to do it, and I thouht to make a array of all the videos. But I do not know if that would be the best way. Can you guys please help me get started. Thank You!
EDIT: I just read this to myself, I repeat myself so much. LOL thanks!
Posted: Thu Feb 02, 2006 1:26 pm
by nincha
name yuor videos video0, video1, video2, video3,....... video[max]
Code: Select all
for($i=0; $i<=max;$i++){
echo "<a href=/playvideo?videoname=video".$i.">Play My Video!</a>";
}
and for other page
Code: Select all
<embed src=<? echo $_GET["videoname"] ?> other attributes>
Posted: Thu Feb 02, 2006 2:21 pm
by m3mn0n
Don't forget a
<br /> and
\n at the end of that echo.

Posted: Thu Feb 02, 2006 3:56 pm
by nickman013
Can i make it video[with a name in here] so for example.. video[joes] ?
will that work?
Posted: Thu Feb 02, 2006 4:09 pm
by shiznatix
yes
Posted: Thu Feb 02, 2006 4:09 pm
by John Cartwright
nickman013 wrote:Can i make it video[with a name in here] so for example.. video[joes] ?
will that work?
The best approach at this IMO would be to store all the file names into a database .. this way you can better organize things and benfit from others features you could possibly add.
Code: Select all
<?php
$clause = '';
if (!empty($_GET['id'])) {
$clause = 'WHERE ';
$clause .= (is_numeric($_GET['id'])
? '`id` ';
: '`fileName` '
);
$clause .= '= \''. mysql_real_escape_string($_GET['id']) .'\' LIMIT 1';
}
$sql = 'SELECT `fileName` FROM `videos` '. $clause .'; ?>
This will allow you to pass links as a filename or by id.. as in
videos.php?id=4
videos.php?id=jcartGoneWild
Posted: Thu Feb 02, 2006 6:51 pm
by nickman013
cool.
so to make my databaase, i will need to fields, one with autoincrement for the id? and another for the file name?
Posted: Thu Feb 02, 2006 7:06 pm
by raghavan20
a sample db would be..
Code: Select all
id int not null auto_increment primary key
name varchar(50) /* general name of the file; you can even custom name the file or you do not need name at all */
Category varchar(50) /* You can have a separate table for categories and include category id here */
OtherIdentificationField varchar(50) /* singer / name of the album */
fileLocation varchar(100) /* Location of the media file can be anywhere; provided this to href of 'a' tag */
Description /* File description */
engine = myisam /* for full text search */
Posted: Thu Feb 02, 2006 8:00 pm
by nickman013
I just need 3 fields, i dont need it to be a monster DB with all of the info to put in.
I tried to make the table based on my knowledge, and what I thought
and this is the code for the table mySQL created for me
Code: Select all
SQL query:
CREATE TABLE `videos` (
`ID` INT( 99 ) AUTO_INCREMENT ,
`Name` BLOB,
`Filename` BLOB,
PRIMARY KEY ( `ID` )
) TYPE = MYISAM ;
would that work?
EDIT: I changed Blob to text.
Posted: Thu Feb 02, 2006 8:13 pm
by raghavan20
you do not need either a blob or text...
you are not going to store massive information in it so use varchar(length) or use tinyblob if you need.
Posted: Thu Feb 02, 2006 8:14 pm
by nickman013
ok so i will change it to that, how would i add the information, like rows?
Posted: Thu Feb 02, 2006 8:16 pm
by John Cartwright
create a run-once script using
glob() or
opendir() and
readdir() to capture all the filenames and insert them only into the db..
make sure you only run it once though

Posted: Thu Feb 02, 2006 8:23 pm
by nickman013
i only got like 10 videos so far, so i am just going to do it manually, easier for me.
any way. to add videos now, i am going to
1. Insert
2. Leaving ID blank (because it is auto_increment)
3. Typing in name and file name.
When I do that and insert videos and click browse, it looks just how I thought it would, good. lol.
Now How do I get it into a link and play it??
Again,
I want the video to be played on the same page.
So
http://www.example.com/play.php?id=1 <-- I want that to play the video with the ID 1 in the database.
Posted: Thu Feb 02, 2006 8:29 pm
by John Cartwright
What are you asking? How to you embed a video or how to get the information from the db?
Posted: Thu Feb 02, 2006 8:31 pm
by raghavan20
I am trying to list files in a directory which match any one of the two extensions but the syntax does not work...I tried this from a snippet in PHP Manual..
Code: Select all
<pre>
<?php
echo "Print php files:<br />"; print_r(glob("*.php"));
echo "Print php and xml files:<br />"; print_r(glob("*.php;*.xml"));
echo "Print all files:<br />"; print_r(glob("*.*"));
?>
</pre>
output:
Code: Select all
Print php files:Array
(
[0] => dbConnection.php
[1] => phpinfo.php
[2] => regex.php
[3] => secondConnection.php
[4] => timediff.php
[5] => timer.php
)
Print php and xml files:Array
(
)
Print all files:Array
(
[0] => dbConnection.php
[1] => international.xml
[2] => phpinfo.php
[3] => regex.php
[4] => secondConnection.php
[5] => timediff.php
[6] => timer.php
)