Closed jgcaruso closed 10 months ago
Thanks for a nicely detailed bug report!
This does seem weird, but someone will have to look and see whether this is intentional behavior or not.
I believe VHS re-sets its internal xhr
on load and doesn't try to keep around the beforeRequest
that it was given.
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.
It looks like the inclusion of the new xhr-hooks-ready event and player.tech().vhs.xhr.onRequest
is a more stable way of overriding beforeRequest
and after refactoring my code to use it, it appears to be applied consistently before any xhr requests AND it also appears to be correctly re-applied on source change.
I'm closing this since it appears to be resolved. If I run into any new issues, I'll open a new issue.
Description
When providing a custom function for
beforeRequest
it appears to work fine until the source is reloaded when using thereloadSourceOnError
plugin. When reload occurs the function is removed.It isn't clear if this is working as intended or not since this behaviour isn't described in the documentation.
When using the global
videojs.Vhs.xhr.beforeRequest
it works as expected, but I need to use the per-player version because I need to check player state for some options.Steps to reproduce
I've created the following codepen snippet to demonstrate the issue https://codepen.io/jgcaruso/pen/OJxaJwX
beforeRequest
is executedrunOnce
const at the top of the page tofalse
it will allow thebeforeRequest
function to be checked continuously if it is missing, and it will then be readdedResults
Expected
I expected
beforeRequest
to be maintained for the lifetime of the video player, unless modified by my code.Actual
The
beforeRequest
is removed whenreload
is called inside of thereloadSourceOnError
plugin.Error output
Nope
Additional Information
Please include any additional information necessary here. Including the following:
versions
videojs
v7.17.0
browsers
latest firefox, chrome. (Safari doesn't appear to support
beforeRequest
)OSes
macos (but I assume all OSes)
plugins
are any videojs plugins being used on the page? If so, please list them below.
The
reloadSourceOnError
plugin provided by videojs (no special imports, just core videojs)