-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
fix: loss of crossOrigin value when loadMedia is called #8085
Conversation
Codecov Report
@@ Coverage Diff @@
## main #8085 +/- ##
=========================================
+ Coverage 0 82.42% +82.42%
=========================================
Files 0 112 +112
Lines 0 7477 +7477
Branches 0 1801 +1801
=========================================
+ Hits 0 6163 +6163
- Misses 0 1314 +1314
... and 111 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
f82fe5d
to
7f9ae89
Compare
7f9ae89
to
1b35a17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me overall, but I'm not totally confident that the crossorigin setting is something we want to carry across source loads.
Perhaps an alternative would be calling player.crossOrigin()
in the ready
callback?
player.loadMedia({...}, () => {
player.crossOrigin('anonymous');
});
Or would that potentially be too late?
@misteroneill thank you for taking the time to review this PR 👍🏽
TL;DR Quick answer, yes it will work. Maybe I can add a little more context regarding this PR. This PR is the result of this issue #8068 and the comments #8068 (comment) and #8068 (comment) According to the However, this function does much more, it resets the player, but also deletes and rebuilds the video element. The consequence is the creation of a new playback session losing properties that are important for the developer and interesting for the user playback experience (not detailed as it's out of the scope of this PR). The important property for the developer
Lines 776 to 777 in 1491d71
Demonstration
const player videojs('player', {crossorigin : 'anonymous'});
player.el().firstChild.crossOrigin; // -> anonymous
player.options().crossorigin; // -> anonymous
player.crossorigin(); // -> anonymous
player.src('...')
player.el().firstChild.crossOrigin; // -> anonymous
player.options().crossorigin; // -> anonymous
player.crossorigin(); // -> anonymous
player.loadMedia('...')
player.el().firstChild.crossOrigin; // -> null
player.options().crossorigin; // -> anonymous
player.crossorigin(); // -> null This means that these two functions behave very differently. Code referencesThe workflow leading to the loss of this property: Line 1274 in 1491d71
Line 1125 in 866ef24
The fix would have been more appropriate in Lines 1152 to 1169 in 866ef24
Line 1196 in 866ef24
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great explanation, I see the issue now - thank you!
While we're at it, should the object that loadMedia takes accept a crossOrigin property to force the value to something specific? This would be an additional feature and can come in a separate PR. I think this change is fine as is. |
I'm going to accept your comment as a second approval @gkatsev 😄 |
Description
This PR fixes the deletion of the
crossOrigin
value whenloadMedia
is called.Fixes: #8086
Specific Changes proposed
crossOrigin
beforereset
deletes itcrossOrigin
afterreset
has been calledcrossOrigin
method is called beforeloadMedia
crossOrigin
value is passed via the options thenloadMedia
is calledcrossOrigin
property thenloadMedia
is calledRequirements Checklist