About double click on player
Description
Hello I have been using vjs for like 10 years now. During most of these years, there was no fonction to double click on the player to go full screen so someone helped me out with something like this
<script>var vid1 = videojs('live_player'); vid1.persistvolume({ namespace: "videojs-user-volume" }); vid1.on('dblclick', function() { vid1.requestFullscreen(); }); vid1.on('dblclick', function() { vid1.exitFullscreen(); });
Until very recently I discovered that this feature was now builtin and so the code unnecesarry . Great.
I also have this piece of code
vid1.on("play",function(e){console.log('Hls started!');setTimeout(function() {vid1.pause()}, 7200000); });
When you open a page with a vjs player, the console write "Hls started!" which is the expected behavior. But it also does the same when you go full screen by double clicking, either using my old way, or the new one builtin in the player. My point is it seems that double clicking the player reset the player state, like a sort of OFF ON .
You must think, , so what?
Well I m using a nice little plugin, that I actually never deployed because I thought it wasn't working properly. Actually it does but since double clicking reset the player state and the plugin being a timer that display a message to stop the video feed after a while depending on how long the video has been playing makes it unusable
https://github.com/TylerZubke/Videojs-AFK-Monitor
So now I m stuck with this because at the moment, it seems my only option is to disable the double click so the plugin works the way I want to. but I really wouldn't want that as double clicking a screen to go full is just so intuitive and expected behavior.
videojs("my-player", {
userActions: {
doubleClick: false
}
});
I do not provide a test page as I don't feel it's necessary, this is more a discussion.
Reduced test case
https://stackoverflow.com/help/minimal-reproducible-example
Steps to reproduce
1.described in the post 2. 3.
Errors
No response
What version of Video.js are you using?
8.20
Video.js plugins used.
afk monitor
What browser(s) including version(s) does this occur with?
all
What OS(es) and version(s) does this occur with?
all
just adding that actually I had to insert this in the data-setup for it to work
data-setup='{"userActions": {"doubleClick": false }}'
as writing this after the player won't work. but anyway, this is not the issue for me
<script>var vid1 = videojs('yourplayer', { userActions: { doubleClick: false }});</script>
If you have set up a player with data-setup, videojs(id) called later is a getter that only returns the already initialised player. A second argument is ignored, that is only used when first initialising a player.
The double-click does not "reset" the player. It calls the browser's fullscreen API, same as a click on the fullscreen button: https://github.com/videojs/video.js/blob/19ca3f2ebe0ec7f0374fa3bc7df1457f9f185823/src/js/player.js#L2015-L2062
sorry but the players's behavior is different between double clicking to go fullscreen and using the fullscreen button,
The main difference is that with the dblclick event, you end up getting two click events as well. So, it gets paused and unpaused as part of the gesture. Unfortunately, there isn't a way to prevent this without delaying the normal click event behavior.
Can you elaborate on what you mean by "reset player state"?
exactly. which is quite what I tried to say with my own words I did a small screen recording which just shows that https://mega.nz/file/N1Ik3LLY#MpJRy9IKocrBBSY5GnXF3qhwNZOcjFcaLmtUj5ZrwFs
maybe it's not resetting the player state as a whole but it does reset the start time, which make the timer plugin quite useless.
yes the only way would be to be able to delay the start event on a single click to make a difference with a very quick double click I guess. so the player wouldn't off on