diff --git a/docs/guides/options.md b/docs/guides/options.md index bfcd5fced5..aa04643abb 100644 --- a/docs/guides/options.md +++ b/docs/guides/options.md @@ -45,6 +45,7 @@ * [techCanOverridePoster](#techcanoverrideposter) * [techOrder](#techorder) * [userActions](#useractions) + * [userActions.click](#useractionsclick) * [userActions.doubleClick](#useractionsdoubleclick) * [userActions.hotkeys](#useractionshotkeys) * [userActions.hotkeys.fullscreenKey](#useractionshotkeysfullscreenkey) @@ -443,6 +444,40 @@ Defines the order in which Video.js techs are preferred. By default, this means > Type: `Object` +### `userActions.click` + +> Type: `boolean|function` + +Controls how clicking on the player/tech operates. If set to `false`, clicking is disabled and will no longer cause the player to toggle between paused and playing. + +```js +videojs('my-player', { + userActions: { + click: false + } +}); +``` + +If undefined or set to `true`, clicking is enabled and toggles the player between paused and play. To override the default click handling, set `userActions.click` to a function which accepts a `click` event (in this example it will request Full Screen, the same as a `userAction.doubleClick`): + +```js +function myClickHandler(event) = { + // `this` is the player in this context + + if (this.isFullscreen()) { + this.exitFullscreen(); + } else { + this.requestFullscreen(); + } +}; + +videojs('my-player', { + userActions: { + click: myClickHandler + } +}); +``` + ### `userActions.doubleClick` > Type: `boolean|function` diff --git a/sandbox/userAction-click.html.example b/sandbox/userAction-click.html.example new file mode 100644 index 0000000000..dcb16cd03e --- /dev/null +++ b/sandbox/userAction-click.html.example @@ -0,0 +1,48 @@ + + +
+ +You can use /sandbox/ for writing and testing your own code. Nothing in /sandbox/ will get checked into the repo, except files that end in .example (so don't edit or add those files). To get started run `npm start` and open the index.html
+npm start+
open http://localhost:9999/sandbox/index.html+