-
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
Require videojs-vtt.js
via require rather than concat
#3919
Changes from all commits
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ import { bufferedPercent } from '../utils/buffer.js'; | |
import MediaError from '../media-error.js'; | ||
import window from 'global/window'; | ||
import document from 'global/document'; | ||
import {isPlain} from '../utils/obj'; | ||
|
||
/** | ||
* An Object containing a structure like: `{src: 'url', type: 'mimetype'}` or string | ||
|
@@ -522,13 +523,27 @@ class Tech extends Component { | |
* | ||
* @fires Tech#vttjsloaded | ||
* @fires Tech#vttjserror | ||
* @fires Tech#texttrackchange | ||
*/ | ||
addWebVttScript_() { | ||
if (!window.WebVTT && this.el().parentNode !== null && this.el().parentNode !== undefined) { | ||
const vtt = require('videojs-vtt.js'); | ||
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, this requires vttjs and then below, we make sure that it becomes available globally unless the vttjs option was provided. In the novtt build, a transform tells browserify not to include this file in the output? 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, we use the vtt.js option if we have it, if not we use the require if it is available (which it won't be for novtt builds), otherwise we use the cdn url. The transform that you mention works like this: 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. Cool, just wanted to confirm I'm understanding it correctly. |
||
|
||
// load via require if available and vtt.js script location was not passed in | ||
// as an option. novtt builds will turn the above require call into an empty object | ||
// which will cause this if check to always fail. | ||
if (!this.options_['vtt.js'] && isPlain(vtt) && Object.keys(vtt).length > 0) { | ||
Object.keys(vtt).forEach(function(k) { | ||
window[k] = vtt[k]; | ||
}); | ||
this.trigger('vttjsloaded'); | ||
return; | ||
} | ||
|
||
// load vtt.js via the script location option or the cdn of no location was | ||
// passed in | ||
const script = document.createElement('script'); | ||
|
||
script.src = this.options_['vtt.js'] || '../node_modules/videojs-vtt.js/dist/vtt.js'; | ||
script.src = this.options_['vtt.js'] || 'https://cdn.rawgit.com/gkatsev/vtt.js/vjs-v0.12.1/dist/vtt.min.js'; | ||
script.onload = () => { | ||
/** | ||
* Fired when vtt.js is loaded. | ||
|
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.
so,
build
is now the main task and takes the job of bothbuild
anddist
?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.
Yeah, the difference between the two was that
dist
would replace the vtt.js string path with a url to the cdn. Since we will require vtt.js by default when we build it isn't really needed to do them separately