Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: playUserInteraction & pauseUserInteraction #2786

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Akryum
Copy link
Contributor

@Akryum Akryum commented May 14, 2020

Added two new properties to MediaElementPlayer (with docs):

  • playUserInteraction: Returns whether the last play call was initiated from user interaction
  • pauseUserInteraction: Returns whether the last pause call was initiated from user interaction

Example usage (for example to synchronize video events over Websockets):

mediaElement.addEventListener('play', () => {
  if (player.playUserInteraction) {
    // Example: Send event to Websocket
  }
})

mediaElement.addEventListener('pause', () => {
  const userInteraction = this.player.pauseUserInteraction &&
      // Handle when video is ended (dispatches a `pause` event)
      this.player.currentTime < this.player.duration
  if (userInteraction) {
    // Example: Send event to Websocket
  }
})

@coveralls
Copy link

coveralls commented May 14, 2020

Coverage Status

Coverage remained the same at 74.376% when pulling a86a038 on Akryum:feat-play-pause-interaction into b9e74bd on mediaelement:master.

Copy link
Collaborator

@karawitan karawitan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@VincentGarreau
Copy link

It could be great to merge it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants