Hi,
I got this piece of code that displays all the .flv files in a certain folder as links to download them. I also have code which displays an embedded video player however a static link to the video is used.
Can someone please help me link these two codes together so that when the link of a video in the first piece of code is clicked it will take it to the embedded video player page and play the appropriate video. I would imagine this involves passing the .flv file location into the href but I am a total noob so don't know how to!
I've been told to pass reference the video I want to play in a URL query string (e.g. "videoplayer.php?video=myvideo") and also use the $_GET function in the video player script. Can anyone tell me how to do this exactly (i.e. what code to include and where)?
Please help if you can. Thanks.
Displays all .flv files currently in the folder:
<?php $current_dir = "includes/videos/"; // Location to read files from. $dir = opendir($current_dir); // Opens the directory. echo ("<p><h1>Video Tutorials:</h1></p><hr><br />"); while ($file = readdir($dir)) // while loop { $parts = explode(".", $file); // pull apart the name and dissect by period if (is_array($parts) && count($parts) > 1) { // does the dissected array have more than one part $extension = end($parts); // set to we can see last file extension if ($extension == "flv"){ // Set allowable file extensions. echo "<a href=\"$current_dir/$file\" target=\"_blank\"> $file </a><br />"; // Link to location of video. } } } echo "<hr><br />"; closedir($dir); // Close the directory. ?> </body> </html>/CODE]
Embedded video player:
[CODE]<html> <head> <title>Videos</title> <script src="flowplayer/example/flowplayer-3.1.4.min.js"></script> </head> <body> <a href="includes/videos/testflash.flv" style="display:block;width:425px;height:300px;" id="player"> </a> <script language="JavaScript"> flowplayer("player", "flowplayer/flowplayer-3.1.5.swf"); </script> </body> </html>