Video.js: player pause/play with a tap on mobile

Created on 14 Dec 2017  路  4Comments  路  Source: videojs/video.js

Hello.
On smartphones if you tap on video it just showing controls so you need to tap second time on the controls to play/pause. Is there any way to video.js player act similar on mobile as on desktop. One tap on video (not controls) play second tap pause?

Most helpful comment

click and tap events are not fired on android (only tested with android v8)

tap event only display controlbar.

Is there a a way to override tap event managed by player ?

UPDATE : touchstart event is well fired
FYI, my goal is to enable play/pause when tap on video

All 4 comments

You probably can add this functionality by listening to the click event on the player and then toggling playback.

Hope that helps.

I actually want the "touch" event of mobile.Should I add it to the player('#player-id')?

You should still be getting a click event on mobile as well, but you can also listen to the tap event we trigger.
Yeah, it's basically just:

var player = videojs('#player-id');
// can also be `tap` or `touchend` or some other event instead of `click`
player.on('click', function() {
  if (player.paused()) {
    player.play();
  } else {
    player.pause();
  }
});

click and tap events are not fired on android (only tested with android v8)

tap event only display controlbar.

Is there a a way to override tap event managed by player ?

UPDATE : touchstart event is well fired
FYI, my goal is to enable play/pause when tap on video

Was this page helpful?
0 / 5 - 0 ratings

Related issues

askaliuk picture askaliuk  路  3Comments

stephanedemotte picture stephanedemotte  路  4Comments

uikoo9 picture uikoo9  路  4Comments

onigetoc picture onigetoc  路  4Comments

zhulduz picture zhulduz  路  3Comments