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

Return a Promise From play() when possible #3927

Closed
brandonocasey opened this issue Jan 9, 2017 · 11 comments
Closed

Return a Promise From play() when possible #3927

brandonocasey opened this issue Jan 9, 2017 · 11 comments

Comments

@brandonocasey
Copy link
Contributor

Description

There is currently a PR (#3907) that returns the native value of play to the user. In some cases (such a newer version of Chrome) this will be a Promise.

I think that we should try to always return a Promise if the browser supports them or a Promise library is provided (window.Promise || this.options_.Promise). This means that we will return the native Promise from play() if it is returned and return a "psuedo-native" Promise if play() does not return a Promise.

We will also have to be mindful of browsers that don't support promises at all and the specification for Promises from play.

@misteroneill
Copy link
Member

This was actually a question at the meetup yesterday: would we support a polyfill or creating our own promise. So, that's a vote in this direction, I'd say.

@gkatsev
Copy link
Member

gkatsev commented Jan 12, 2017

Yup, I don't want to write our own promise implementation :)

@misteroneill
Copy link
Member

Sorry, I meant we'd return a Promise as @brandonocasey is suggesting - not "create our own". Poor phrasing. 😆

@shikkaba
Copy link

Is there any update on this?

@gkatsev
Copy link
Member

gkatsev commented Oct 24, 2017

@shikkaba in Video.js v6, we already are returning a Promise from play() if the browser supports this. We have not made progress on making our own promise for the times that the browser doesn't support it.

@shikkaba
Copy link

shikkaba commented Oct 24, 2017

@gkatsev Thank you for the reply. I'm just wondering because in Chrome I'm seeing the following:
Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause().

@KevinBrogan
Copy link
Contributor

KevinBrogan commented May 29, 2018

@gkatsev videojs 7 does not return the native promise result from play()

@stale
Copy link

stale bot commented Jul 28, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the outdated Things closed automatically by stalebot label Jul 28, 2018
@gkatsev gkatsev added confirmed and removed outdated Things closed automatically by stalebot labels Jul 28, 2018
@gkatsev
Copy link
Member

gkatsev commented Aug 10, 2018

Actually, re-opening this one for the follow-up work for IE11 and browsers that don't return a promise from play().

@darktasevski
Copy link

darktasevski commented Apr 8, 2020

@gkatsev Any update on this? 🙂

We have some issues with play() not being resolved on Smart TVs (LG, Tizen) and older browsers (IE 11). Not awaiting Promise is, in some cases, causing other errors, like:

  • InvalidStateError Failed to read the 'buffered' property from 'SourceBuffer',
  • NotSupportedError Failed to load because no supported source was found.

Example stack trace from one of our errors:

Screenshot 2020-04-08 15 46 46

This is not happening if we await play(), but play() is not resolving sometimes so it's not an ideal solution.

@gkatsev
Copy link
Member

gkatsev commented Apr 10, 2020

So, looks like this issue should be closed. At some point we did add promise support for older browsers. However, you must either provide videojs with a promise polyfill or include a promise polyfill globally on those platforms.

@Puritanic can I ask you to open a new issue with more info filled out in the issue template? Like video.js versions and preferably a reduced test case.

@gkatsev gkatsev closed this as completed Apr 10, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants