So like the title implies I am trying to use php to make a javascript link that changes the video playing in an html5 player to one of the file links stored in an array...if you haven't closed the topic at this point I'm surprised. I have had no trouble changing the file type to a set file using a button using html with this code
Ok a small bit of info on my code, "video" is the name of the iframe that the html5 player, and mediaSwitch is a javascript function I store that will change the file that is playing to whatever is passed in as a parameter. What my final goal is to have a video player beside a small web app (this is meant for an ipad) and that web app will list all the files and if they are a .mp4 file clicking the link will change the video in the player to that video. I have everything working and I can display the files and do a raw link to them but when the php script generates the link for the file it doesn't execute the code. I use the following to try and generate the link.
So for this code $ext is a working variable that holds the files extension, files[j] is stored inside the $files[] array and $j is just the int used in the for loop.
When I load the page the script works without any errors but clicking the link only gets the above code repeated only with the variables replaced with the correct file. The only problem is the link so if anyone has an idea for what I can do it would be greatly appreciated.
A screen shot of the script running locally (with the exception of the .php file which is delivered by a server) is attached in case anyone is interested/needs a visual representation to understand it better.
Code:
<input type="button" value="Switch" onClick="parent.video.mediaSwitch('file2.mp4')">
Ok a small bit of info on my code, "video" is the name of the iframe that the html5 player, and mediaSwitch is a javascript function I store that will change the file that is playing to whatever is passed in as a parameter. What my final goal is to have a video player beside a small web app (this is meant for an ipad) and that web app will list all the files and if they are a .mp4 file clicking the link will change the video in the player to that video. I have everything working and I can display the files and do a raw link to them but when the php script generates the link for the file it doesn't execute the code. I use the following to try and generate the link.
Code:
if ($ext == "mp4") {
echo "<li class='menu'><a href='javascript: parent.video.mediaSwitch($files[$j])'>";
}
So for this code $ext is a working variable that holds the files extension, files[j] is stored inside the $files[] array and $j is just the int used in the for loop.
When I load the page the script works without any errors but clicking the link only gets the above code repeated only with the variables replaced with the correct file. The only problem is the link so if anyone has an idea for what I can do it would be greatly appreciated.
A screen shot of the script running locally (with the exception of the .php file which is delivered by a server) is attached in case anyone is interested/needs a visual representation to understand it better.