Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Overriding the Onclick Event


I have the player embedded in a webpage with all controls turned off (all you can see is the video). If I click on the player, the video stops. if I then click again, it starts. Is there anyway to override that? Even better, is there a way to get the coordinates for the click returned? Thanks!

9 Community Answers

Pablo

JW Player Support Agent  
-2 rated :

You can’t override the click behavior, but you can get the coordinates of the click in JavaScript by using the ClickProxy plugin (http://www.longtailvideo.com/addons/plugins/68/Clickproxy).

JW Player

User  
0 rated :

This is very helpful: In implementing it however, I'm running into a problem. I've got the following javascript function setup:

function clickListener(obj) {
alert(document.getElementById(obj['id']));
};

An alert box pops up when I click on the control, but it says "null". I've got a similar function setup:

function playerReady(obj) {
alert(document.getElementById(obj['id']));
};

and it will say [object] in the alert box. What am I doing wrong on the "ClickListener" event? I can't get a reference to the object that was clicked.

JW Player

User  
0 rated :


Test Page with the Clickproxy plugin functioning with a v5.2.1148 JW Player here:

*http://willswonders.myip.org:8074/player5/Simple_YouTube_Channel_email_v5.html*

JW Player

User  
0 rated :

Thank you! I'm finding that the "ID" is returning 0 for each control on the page. For the PlayerReady function, "obj['id']" returns the ID of the object. However, the clicklistener function returns 0. Is "ID" not supported in the same way for clicklistener?

JW Player

User  
0 rated :

Actually, just figured it out. I set the ID in the Flashvars and I am good now. Thanks!

JW Player

User  
0 rated :

I'm having the same problem. I have 2 playlists on a page and I need to get their id. Unfortunately, the player code is being created by wordTube (a WordPress plugin). Can anyone help me pass the id to a javascript function?

Here's an example from the page source:

<script type="text/javascript" defer="defer">
var WT1_1 = {
params : {
wmode : "opaque",
allowscriptaccess : "always",
allownetworking : "all"},
flashvars : {
file : "http%3A%2F%2Fwww.mysite.com%2Fvideos%2Findex.php%3Fxspf%3Dtrue%26id%3D1",
volume : "80",
bufferlength : "5",
quality : "false",
'logo.hide' : "false",
plugins : "clickproxy",
id : "video_player",
shuffle : "false",
playlist : "bottom"},
attr : {
id : "WT1",
name : "WT1"},
start : function() {
swfobject.embedSWF("http://www.mysite.com/videos/wp-content/uploads/player-licensed.swf", "WT1_1", "240", "400", "9.0.0", false, this.flashvars, this.params , this.attr );
}
}
WT1_1.start();
</script>

JW Player

User  
0 rated :

One note on the code above, WT1 changes with each playlist you create (i.e.: WT2, WT3, etc.).

Here is what I would like to do:

<script type="text/javascript">
function clickListener(obj) {
var player_id = document.getElementById(obj['id']);
if (player_id == 1) {
window.open('http://www.THISsites.com');
} else {
window.open('http://www.THATsites.com');
}
</script>

JW Player

User  
0 rated :

Not quite sure what you mean, Zach. I'm using clickproxy. When the user clicks on the video, I want to direct them to a site.

I realize I can't have a separate link for each video. So, I thought of creating two playlists with different ids, one for each site.

JW Player

User  
0 rated :

Dear Zach,

A thousand blessings on your house!!!!! That is EXACTLY what I needed! Thank you, thank you, thank you!

This question has received the maximum number of answers.