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

Chrome browser: uncaught promise, when pausing/playing video #6998

Closed
sebastianvog opened this issue Dec 16, 2020 · 3 comments · Fixed by #7189
Closed

Chrome browser: uncaught promise, when pausing/playing video #6998

sebastianvog opened this issue Dec 16, 2020 · 3 comments · Fixed by #7189

Comments

@sebastianvog
Copy link

Description

When playing a video on a slow connection in Chrome, e.g. https://videojs.com/advanced?video=disneys-oceans
It's possible that a uncaught promise is thrown in the javascript console when clicking pause/play while the video has not loaded yet.

Steps to reproduce

  1. With google chrome to the demo sample https://videojs.com/advanced/?video=disneys-oceans.
  2. Before Starting the video change the "network" in the chrome javascript console to "Slow 3G" to simulate a slow connection
    2.Start the video, and scrub/drag to the middle of the video
  3. While the video is attempt to load/reload, press the pause/play buttons quickly

Results

Expected

No errors displayed in javascript console

Actual

Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause(). https://goo.gl/LdLk22

Error output

Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause(). https://goo.gl/LdLk22

Additional Information

Please include any additional information necessary here. Including the following:

versions

videojs

what version of videojs does this occur with?
We are using 7.11.0
Not sure what version runs on https://videojs.com/advanced/?video=disneys-oceans but i would assume the latest version?

browsers

Google Chrome Version 87.0.4280.88 (Official Build) (x86_64)

OSes

OSX Mojave

plugins

@welcome
Copy link

welcome bot commented Dec 16, 2020

👋 Thanks for opening your first issue here! 👋

If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@FredZeng
Copy link
Contributor

FredZeng commented Apr 8, 2021

You can just ignore this error by catching the promise in most situation. In videojs, they use silencePromise to ignore this error.

silencePromise(this.el_.play());
/**
 * Returns whether an object is `Promise`-like (i.e. has a `then` method).
 *
 * @param  {Object}  value
 *         An object that may or may not be `Promise`-like.
 *
 * @return {boolean}
 *         Whether or not the object is `Promise`-like.
 */
export function isPromise(value) {
  return value !== undefined && value !== null && typeof value.then === 'function';
}

/**
 * Silence a Promise-like object.
 *
 * This is useful for avoiding non-harmful, but potentially confusing "uncaught
 * play promise" rejection error messages.
 *
 * @param  {Object} value
 *         An object that may or may not be `Promise`-like.
 */
export function silencePromise(value) {
  if (isPromise(value)) {
    value.then(null, (e) => {});
  }
}

Read carefully over play-request-was-interrupted.
image

@gkatsev
Copy link
Member

gkatsev commented Apr 16, 2021

This is basically expected. We do try and silence these errors, but I guess the play toggle didn't silence the promise.

gkatsev added a commit that referenced this issue Apr 16, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
edirub pushed a commit to edirub/video.js that referenced this issue Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants