Jump to content

Html Video Player need help


Arcader

Recommended Posts

Hey I'm building a video player that just changes the embed video it plays. I have codes to change the embed video but I was woundering how to make it so when I click on a link it will open the video webpage with video I want it to play, and if I click on another link open the same webpage and play a different video. I don't know how to do that. I'll I need to know in other words is send a varible code from webpage to another using only javascript.

Link to comment
Share on other sites

I sugguest using PHP or ASP for this. Javascript doesn't really work that way.What's you video player made in? (Flash?)

Link to comment
Share on other sites

You can get at the query string parameters with javascript, it's just much easier to do it with a server-side technology.You could either write your own method of getting the variables out of the query string staring with something like this:

var query = location.search;var pairs = query.split("&");

Or, you can use a method that aspnetguy posted here awhile ago:http://w3schools.invisionzone.com/index.ph...ost&p=49133

Link to comment
Share on other sites

I looked over this jesh, but I need someone to explain part of it cause I only get so and so much of this

<script>function getQueryVariable(variable) {  var query = window.location.search.substring(1);  var vars = query.split("&");  for (var i=0;i<vars.length;i++) {	var pair = vars[i].split("=");	if (pair[0] == variable) {	  return pair[1];	}  }   alert('Query Variable ' + variable + ' not found');}</script>Now make a request to page.html?x=Hello<script>  alert( getQueryVariable("x") );</script>

Also it might be easyer if someone can tell me how to make it check the html address it is, so I could just make a could that says if (http=http://website.com/video.html#2334) {varible=this}

Link to comment
Share on other sites

Let's say you had your system set up where the page was looking for a query string variable called "video" and depending on what value was stored in "video" it would determine which video was loaded on your page.You could, perhaps, store the URL to your videos in an array:

var videos = new Array();videos[0] = "somevideo.mpeg";videos[1] = "anothervideo.mpeg";videos[2] = "athirdvideo.mpeg";

And you could link to your video using something like this:

<a href="?video=0">View Some Video</a><a href="?video=1">View Another Video</a><a href="?video=2">View a Third Video</a>

Then, using that code you posted, you could get at the variable passed in the link like so:

var videoIndex = getQueryVariable("video");

And, then, you can get the URL to the video out of your array like this so that you can use it to switch the videos on the page:

var videoURL = videos[videoIndex];

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...