Wednesday, October 7, 2009

How to use get variables with flv player

I have many videos on my site that I need to have inside the player. But in order for my customers to be able to easily navigate thru all my videos and view a specific video, instead of scrolling thru a list with small thumbnail images inside the player, I have a gallery page with an explanation to each video, and I'm wondering if it's possible to link an image on a different html page to a specific video inside the playlist of the player? Meaning that when the customer clicks on an image on a different html page to view the video, they are taken to the html page with the player and that specific video starts to play..

At this stage I have around 70 videos on my site, and it will continue to grow, and the thumbnails in the player doesn't give me the overview that I can get from having larger images with an explanation as to what type of video it is.

I want to avoid having a single flash player for each video and would really like to be able to have one single player with all my videos, and then simply link an image on a different html page to drive that video in the webstunning player.

Kind regards

Chris

Answer

Yes, it's possible.
Use following links to the page with the flv player:

http://www.YourDomain.com/playerPage.htm?movie=1
http://www.YourDomain.com/playerPage.htm?movie=68
http://www.YourDomain.com/playerPage.htm?movie=69

Add this code to the end of the page with the WebStunning player:

<script type="text/javascript">

function parseGetVars() {
var ar = new Array();
var q = unescape(top.location.search.substring(1));
var pairs = q.split(/\&/);
for (var i=0;pairs[i];i++) {
var nv = pairs[i].split(/\=/);
ar[nv[0]] = nv[1];
}
return ar;
}
function playWhenReady(){
var wso = swfobject.getObjectById('WSplayer');
if(document.readyState){
if(document.readyState=="complete" && wso.getReadyState()=="ready"){
wso.JS_PlayVideoNum(movieNum);
}else{
setTimeout("playWhenReady()",200);
}
}else{
if(wso && wso.getReadyState()=="ready"){
wso.JS_PlayVideoNum(movieNum);
}else{
setTimeout("playWhenReady()",200);
}
}
}

var gVars = parseGetVars();
var movieNum = gVars['movie'];
if(movieNum)playWhenReady();
</script>

No comments:

Post a Comment