-
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
setSrc clears currentSource_ after loadstart #3285
Changes from 2 commits
06dcc61
8d89829
132e107
47873df
f10fc92
84810c2
64be2ab
43aac04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -99,7 +99,7 @@ class Html5 extends Tech { | |||||||||
|
||||||||||
if (this.featuresNativeTextTracks) { | ||||||||||
if (crossoriginTracks) { | ||||||||||
log.warn(tsml`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used. | ||||||||||
log.warn(tsml`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will tell me editor to cut it out with the whitespace trimming. |
||||||||||
This may prevent text tracks from loading.`); | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -549,9 +549,19 @@ class Html5 extends Tech { | |||||||||
* @method setSrc | ||||||||||
*/ | ||||||||||
setSrc(src) { | ||||||||||
let loadstartlistener = Html5.prototype.loadStartListener_; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we explicitly using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's just arbitrary. |
||||||||||
|
||||||||||
this.off(this.el_, 'loadstart', loadstartlistener); | ||||||||||
this.one(this.el_, 'loadstart', () => this.one(this.el_, 'loadstart', loadstartlistener)); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this assume setSrc() is the only valid way to modify the video element's source? What about setSource()? Is there a way this can be written that doesn't require adding and removing listeners after the tech's creation? You might be able to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, this function literal wouldn't get cleared properly on subsequent calls to setSrc() which would cause the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this doesn't account for Lines 1916 to 1919 in 2e2dbde
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the scenario:
loadStartListener_() would be removed on the second call to setSrc() but the inline listener that triggers the loadstartlistener on the next There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, right, the first |
||||||||||
|
||||||||||
this.el_.src = src; | ||||||||||
} | ||||||||||
|
||||||||||
loadStartListener_() { | ||||||||||
this.currentSource_ = null; | ||||||||||
this.disposeSourceHandler(); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Load media into player | ||||||||||
* | ||||||||||
|
@@ -1148,7 +1158,6 @@ Html5.prototype['featuresNativeVideoTracks'] = Html5.supportsNativeVideoTracks() | |||||||||
*/ | ||||||||||
Html5.prototype['featuresNativeAudioTracks'] = Html5.supportsNativeAudioTracks(); | ||||||||||
|
||||||||||
|
||||||||||
// HTML5 Feature detection and Device Fixes --------------------------------- // | ||||||||||
let canPlayType; | ||||||||||
const mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i; | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ var player, tech, el; | |
import Html5 from '../../../src/js/tech/html5.js'; | ||
import * as browser from '../../../src/js/utils/browser.js'; | ||
import document from 'global/document'; | ||
import TestHelpers from '../test-helpers.js'; | ||
import EventTarget from '../../../src/js/event-target.js'; | ||
import * as Fn from '../../../src/js/utils/fn.js'; | ||
|
||
q.module('HTML5', { | ||
'setup': function() { | ||
|
@@ -442,3 +445,28 @@ test('Html5#reset calls Html5.resetMediaElement when called', function() { | |
|
||
Html5.resetMediaElement = oldResetMedia; | ||
}); | ||
|
||
test('Html5#setSrc clears currentSource_ after loadstart', function() { | ||
|
||
let thing = { | ||
off: () => {}, | ||
one: (el, type, fun) => { | ||
el.one(type, Fn.bind(thing, fun)); | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mocking one() and off() may make this test a little too artificial. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does successfully test that setSrc clears contentSource_ after loadstart. Do you have any suggestions on how to make this more real? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd create an object that inherited from EventTarget right in the test here and use that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We tried that. |
||
disposeSourceHandler: () => {}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should verify that this has been called. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea |
||
el_: new EventTarget() | ||
}; | ||
|
||
Html5.prototype.setSrc.call(thing, 'test'); | ||
|
||
thing.currentSource_ = 'test'; | ||
|
||
thing.el_.trigger('loadstart'); | ||
|
||
equal(thing.currentSource_, 'test'); | ||
|
||
thing.el_.trigger('loadstart'); | ||
|
||
equal(thing.currentSource_, null); | ||
|
||
}); |
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.
We have encountered issues with using
Function.prototype
as a no-op due to the way video.js tracks functions by a GUID property. I don't think it would be an issue here, but I think it's safer to never use it. Unfortunately. 😞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.
What do you propose?
() => {}
?