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

Trouble disableling default play/pause on click - JW7+AngularJS


Hi,

I want to disable the default behavior in which the mouse click toggles between play and pause.
Unfortunately, I am not sure if my issue has to do with JWPlayer or with the fact that I am using it within AngularJS.
I am using the following directive

https://github.com/ampervue/ngJWPlayer/blob/master/src/jwplayer.directive.js

where inside the _renderJWPlayerElement function, and after the player.setup, I want to add:

player.on('click', function(event) {
var currentTime = player.getPosition();
$log.log('click', event.clientX, event.clientY, currentTime);

// Do something here

// Try to disable default behavior with
// BEGIN: NOT WORKING
event.preventDefault();
// END: NOT WORKING

});

But the event.preventDefault() produces the following error:

There was an error calling back an event handler for "click". Error: Illegal invocation

and I still get the default behavior.

Any help will be appreciated. Thanks,

2 Community Answers

dkarchmer

User  
0 rated :

I found a solution by simply calling

player.play(true);

instead of the

event.preventDefault();

but I still wonder how can I properly prevent the default behavior.

Alex

JW Player Support Agent  
-1 rated :

Hi, there.

The only built-in way to disable the player toggling playing and pausing the video when you click on the display is to hide the controls by adding controls: false to your setup block.

This question has received the maximum number of answers.