/CC @cpearce @jernoble
With autoplay policies, a media element may not be allowed to play depending on various rules: browser setting, user behaviour on the page, etc. It was suggested to expose this as a permission but because the behaviour is often dependant on past user behaviour on the page [1], it may makes sense to expose the information at a media element level. @cpearce suggested canAutoplay(). The version that returns a promise would work for me.
We could also look into making it more generic such as canPlay() or willPlay() which could be used for other things than autoplay and mostly behave like a dry run and would return the same thing as play() except that it will not start the playback. It may be a bit more painful to handle but may solve more use cases. It would also help resolve situations where autoplay is allowed but playback wouldn't work anyways. Note that one issue with reflecting autoplay for a media element is that it may depend on the availability of the metadata (available tracks for example). We would need to specify what's the expected behaviour with regards to this: should we load the metadata in order to get the information or not? I would rather load all the needed information and call this willPlay() as side effects from calling a method like this may be more expected.
[1]: Chrome allows playback after one user activation on the page; Safari allows playback after one successful playback on the page, etc.
/CC @cpearce @jernoble
With autoplay policies, a media element may not be allowed to play depending on various rules: browser setting, user behaviour on the page, etc. It was suggested to expose this as a permission but because the behaviour is often dependant on past user behaviour on the page [1], it may makes sense to expose the information at a media element level. @cpearce suggested
canAutoplay(). The version that returns a promise would work for me.We could also look into making it more generic such as
canPlay()orwillPlay()which could be used for other things than autoplay and mostly behave like a dry run and would return the same thing asplay()except that it will not start the playback. It may be a bit more painful to handle but may solve more use cases. It would also help resolve situations where autoplay is allowed but playback wouldn't work anyways. Note that one issue with reflecting autoplay for a media element is that it may depend on the availability of the metadata (available tracks for example). We would need to specify what's the expected behaviour with regards to this: should we load the metadata in order to get the information or not? I would rather load all the needed information and call thiswillPlay()as side effects from calling a method like this may be more expected.[1]: Chrome allows playback after one user activation on the page; Safari allows playback after one successful playback on the page, etc.