Custom movie player window (searched, need help)

liunx

Guest
I searched and came acrossthis thread (<!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/showthread.php?s=&threadid=39280">http://www.webdeveloper.com/forum/showt ... adid=39280</a><!-- m -->) about having a custom movie player that opens in a new window. I was wondering if anyone could point me in the right direction to do this... I'm a total n00b as far as code goes, I'm totally used to wysiwyg. I was planning on making a separate page for every movie (basically using my custom media player page I set up like a template), but I knew there had to be a better way to do it where I would only have to make one page and then use some kind of code to determine which movie is played. With my set up I want to have a windows media file on the left side and a description of the movie on the right. How can I do this (or where should I look to find out??)<br />
<br />
Summary: I want to set up a media player just like on gamespot, that has text synchronized with video.<!--content-->Well, if you want only one page, this can be accomplished using a server side language and a database. First, you create a page, a generic movie page. You set it up with html as you like, and then for this part:<br />
<br />
<embed src=http://www.webdeveloper.com/forum/archive/index.php/"mymovie.wma" style="width:300px;height:300px;" /><br />
<br />
With the script picking a different movie based on a variable sent. You could have a link to it in PHP, like: <a href=http://www.webdeveloper.com/forum/archive/index.php/"movie.php?id=2">My Movie</a> And then you use the id sent, which is 2, to select that movie out of the database. You can use it to select descriptions and such as well. But you need to know and have a server side language and database.<!--content-->You could have a link to it in PHP, like: <a href=http://www.webdeveloper.com/forum/archive/index.php/"movie.php?id=2">My Movie</a> And then you use the id sent, which is 2, to select that movie out of the database. <br />
<br />
I have no experience with this kind of thing, can anyone point me in the right direction to get started with this?<!--content-->Like I said, first you find out what kind of server side language/database support you have, then we go from there.<!--content-->Originally posted by MstrBob <br />
Like I said, first you find out what kind of server side language/database support you have, then we go from there. <br />
<br />
host says they have:<br />
<br />
MYSQL 3.23<br />
PhpMyAdmin<br />
<br />
Is that what you mean?<!--content-->yes, you have PHP and MySQL...<br />
try:<br />
<!-- m --><a class="postlink" href="http://www.w3schools.com">http://www.w3schools.com</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.php.net">http://www.php.net</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://dev.mysql.com/doc/mysql/en/index.html">http://dev.mysql.com/doc/mysql/en/index.html</a><!-- m --><!--content-->Originally posted by MstrBob <br />
yes, you have PHP and MySQL...<br />
try:<br />
<!-- m --><a class="postlink" href="http://www.w3schools.com">http://www.w3schools.com</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.php.net">http://www.php.net</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://dev.mysql.com/doc/mysql/en/index.html">http://dev.mysql.com/doc/mysql/en/index.html</a><!-- m --> <br />
<br />
i ran through the basic php tutorials on those sites, i dont really have time tonight to go in depth, maybe tomorrow i will. now i have a basic foothold but theres obviously more i need to figure out, like how you mentioned having a link like: mypage.php?id=2. The tutorials didn't cover anything regarding links or interpreting data based on the link.....<!--content-->Aye, well, with PHP, there are a number of ways to pass variables to different scripts. You can use: Sessions, Cookies, Forms, and Links to pass variables - depending on what you need to do. Now, for something like this, say you need to pass a variable id to your script which chooses the movie from the database. This variable contains the movie's id inside of the database. Your link:<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"movie.php?id=2">My Movie</a><br />
<br />
The question mark (?) states that what follows are variables. The variable's name is 'id' and its value is 2. You could expand this to pass multiple variables by using an amperstand (&) such as:<br />
<br />
script.php?id=2&bar=foo<br />
<br />
Now, your movie script would look something like:<br />
<br />
<br />
<?PHP<br />
/* Makes sure id variable is set */<br />
if(isset($_GET['id'])<br />
{<br />
/* Database's name, username and password to connect*/<br />
$db_username="username";<br />
$db_password="password";<br />
$database="database_name";<br />
$db_host="localhost";<br />
/*Connects to Database*/<br />
$db = mysql_connect($db_host,$db_username,$db_password) or<br />
die("Error: Unable to connect to server.");<br />
mysql_select_db($database, $db) or die("Error: Unable to select database.");<br />
/* selects the field 'movie' from your database table named 'movie_table' where the row id is the same as the value of $_GET['id] */<br />
$result=mysql_query("SELECT `movie` FROM `movie_table` WHERE id='$_GET['id']'");<br />
$movie = mysql_fetch_row($result);<br />
/* Prints the proper html code to display the movie, and the movie source is taken from the database field 'movie', which we just grabbed from the database. */<br />
echo("<embed src=http://www.webdeveloper.com/forum/archive/index.php/\"$movie[0]\" style=\"width:300px;height:300px;\" />");<br />
mysql_close();<br />
} else {<br />
/* If id variable isn't set, returns error message */<br />
echo("That movie could not be found.");<br />
}<br />
?> <br />
<br />
<br />
That'd be your basic starting point, and your script can of course become more advanced to also provide movie dimensions, descriptions, ect. You have to set up a MySQL table, though, named something like movie_table and the above script requires that you at leaste have two fields, id and movie respectively.<!--content-->
 
Back
Top