Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

If beforeRequest is set, reuse it on source changes #983

Merged
merged 4 commits into from
Apr 10, 2017

Conversation

gesinger
Copy link
Contributor

Description

handleSource would replace any preexisting beforeRequest.
Reported in #665
Example of bug: http://jsbin.com/qijehan/2/edit?html,console,output

Specific Changes proposed

Now handleSource checks for a preexisting beforeRequest, and reuses it if it is there.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
  • Reviewed by Two Core Contributors

@@ -674,12 +674,23 @@ const HlsSourceHandler = function(mode) {

let settings = videojs.mergeOptions(options, {hls: {mode}});

let previousBeforeRequest;

if (tech.hls && tech.hls.xhr && tech.hls.xhr.beforeRequest) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to check for tech.hls.xhr.beforeRequest here. Even if beforeRequest is undefined, the next line won't cause an exception.

let previousBeforeRequest;

if (tech.hls && tech.hls.xhr && tech.hls.xhr.beforeRequest) {
previousBeforeRequest = tech.hls.xhr.beforeRequest;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could change this to previousBeforeRequest = tech.hls.xhr.beforeRequest || videojs.Hls.xhr.beforeRequest; This could remove the need for the if statements below to instead just always set tech.hls.xhr.beforeRequest = previousBeforeRequest;. However, the code in its current state may be more understandable, so I'd only consider this comment if you think its an improvement there

@mjneil
Copy link
Contributor

mjneil commented Feb 1, 2017

Many of the people in the issue you referenced mention that using the global override videojs.Hls.xhr.beforeRequest isn't working and the only way to override the function is at runtime. Is that still an issue and does this address that?

@gesinger
Copy link
Contributor Author

Good call @mjneil , changed it so that they can be changed anytime.

@@ -674,13 +674,20 @@ const HlsSourceHandler = function(mode) {

let settings = videojs.mergeOptions(options, {hls: {mode}});

let previousBeforeRequest;

if (tech.hls && tech.hls.xhr) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I feel about this. We should be cleaning up tech.hls on dispose anyway. That we don't is actually a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On dispose is fine, but what about on source changes? Since the hls object is per player, shouldn't it continue to exist and not be disposed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the source handler is disposed of on each source change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, the HLS property on the player is for compatibility reasons. David and I were considering removing the object all together if HLS is used with Video.js 6+

@gesinger gesinger force-pushed the fix-source-change-before-request branch from 102cfd0 to 7986734 Compare April 5, 2017 22:25
@mjneil mjneil merged commit 98405e6 into videojs:master Apr 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants