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!
Please help if you can. Thanks.
Displays all .flv files currently in the folder:
Code: Select all
<?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: Select all
<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>