-
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
Add option to override native audio and video to html5 tech #5074
Changes from 14 commits
9c20c37
1f2461b
e9ed558
397354d
51f2330
ec99367
a158145
59f90d1
c2216ff
99b2105
49a226f
58cd557
1afa8b2
c140236
c359c94
cb15e8f
5af08c9
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 |
---|---|---|
|
@@ -200,6 +200,43 @@ class Html5 extends Tech { | |
}); | ||
} | ||
|
||
/** | ||
* Attempt to force override of native audiio/video tracks. | ||
* | ||
* @param {Boolean} override - If set to true native audio/video will be overridden, | ||
* otherwise native audio/video will potentially be used. | ||
*/ | ||
overrideNativeTracks(override) { | ||
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. might be good to make this a no-op if we aren't changing the override. 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 add either an empty method or a default implementation in tech.js for this. |
||
// If there is no behavioral change don't add/remove listeners | ||
if (override !== (this.featuresNativeAudioTracks && this.featuresNativeAudioTracks)) { | ||
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. copy/paste 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. That took me a minute to spot, good 👀 s |
||
return; | ||
} | ||
|
||
if (this.audioTracksListeners_) { | ||
Object.keys(this.audioTracksListeners_).forEach((eventName) => { | ||
const elTracks = this.el().audioTracks; | ||
|
||
elTracks.removeEventListener(eventName, this.audioTracksListeners_[eventName]); | ||
}); | ||
} | ||
|
||
if (this.videoTracksListeners_) { | ||
Object.keys(this.videoTracksListeners_).forEach((eventName) => { | ||
const elTracks = this.el().videoTracks; | ||
|
||
elTracks.removeEventListener(eventName, this.videoTracksListeners_[eventName]); | ||
}); | ||
} | ||
|
||
this.featuresNativeVideoTracks = !override; | ||
this.featuresNativeAudioTracks = !override; | ||
|
||
this.audioTracksListeners_ = []; | ||
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. should be set to |
||
this.videoTracksListeners_ = []; | ||
|
||
this.proxyNativeTracks_(); | ||
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. so basically, everything above will remove listeners and then we call proxyNativeTracks_ so that if we turn native back on it'll run but if we turned it off, proxyNativeTracks_ will exit early and not run? 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. That sounds right to me. |
||
} | ||
|
||
/** | ||
* Proxy all native track list events to our track lists if the browser we are playing | ||
* in supports that type of track list. | ||
|
@@ -256,6 +293,8 @@ class Html5 extends Tech { | |
} | ||
}; | ||
|
||
this[props.getterName + 'Listeners_'] = listeners; | ||
|
||
Object.keys(listeners).forEach((eventName) => { | ||
const listener = listeners[eventName]; | ||
|
||
|
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.
audiio -> audio