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

Player.play() does not return promise #5362

Closed
Akxe opened this issue Aug 6, 2018 · 4 comments
Closed

Player.play() does not return promise #5362

Akxe opened this issue Aug 6, 2018 · 4 comments

Comments

@Akxe
Copy link
Contributor

Akxe commented Aug 6, 2018

Description

I seem not to get promise from player.play() method call.

Steps to reproduce

  1. Set up player
  2. Call player.play()

Results

Expected

Promise as return value for supported browsers, undefined in others.

Actual

Undefined only.

Additional Information

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

versions

videojs

7.2.0

browsers

Chrome, iOS (probably all that support Promise..., therefor all expect IE)

OSes

Probably all?

A bit of background

player.play() does not work on iOS, if you get source to be played via http request or other asynchronous means. Therefor I need to intercept, if the play method succeeded, or failed. To my knowledge, all browsers that do prevent player.play also supports the promise from play method, therefor we should be able to intercept this and show some button to play the video.

@misteroneill
Copy link
Member

The Player#play() method will currently only return a promise under a few conditions:

  • The player/tech must be ready.
  • The player must have a source.
  • The player must not be changing sources.

We are currently undertaking some work to improve this situation, though, but hopefully that helps you understand the current situation.

@Akxe
Copy link
Contributor Author

Akxe commented Aug 9, 2018

I did work around this using player.el().querySelector('video').play()... I suspect that it is due to having player.src(data.streamPreviewUrl) on previous line. It is somewhat inconvenient as often those two go hand in hand, Maybe, you could pass the rejection, if it happened? It is usually due to safari bug.

@gkatsev
Copy link
Member

gkatsev commented Aug 9, 2018

I'm about to merge #5227 which should greatly improve returning Promise from play() in all cases. Following that, we're going to work on polyfilling the promise as necessary for browsers that don't return a promise from play like IE11.

@gkatsev
Copy link
Member

gkatsev commented Aug 10, 2018

#5227 has been merged and will be released in the next patch release. Going to close this in favor of #3927 to track work for IE11/browser that don't return a promise from play() work.

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

No branches or pull requests

3 participants