Security News
Understanding the Security Concerns of npm Shrinkwrap
Explore the security risks of using npm shrinkwrap, the potential for outdated dependencies, and best practices for mitigating these concerns in your projects.
videojs-errors
Advanced tools
Readme
A plugin that displays user-friendly messages when Video.js encounters an error.
The plugin automatically registers itself when you include videojs.errors.js in your page:
<script src="videojs.errors.js"></script>
You probably want to include the default stylesheet, too. It displays error messages as a semi-transparent overlay on top of the video element itself. It's designed to match up fairly well with the default Video.js styles:
<link href="videojs.errors.css" rel="stylesheet">
If you're not a fan of the default styling, you can drop in your own stylesheet. The only new element to worry about is vjs-errors-dialog
which is the container for the error messages.
The plugin supports multiple languages when using Video.JS v4.7.3 or greater. In order to add additional language support, add the language file after your plugin as follows:
<script src="videojs.errors.js"></script>
<script src="lang/es.js"></script>
Note: A formatted example is available for Spanish under 'lang/es.js'.
Once you've initialized Video.js, you can activate the errors plugin. The plugin has a set of default error messages for the standard HTML5 video errors keyed off their runtime values:
1
)2
)3
)4
)5
)Additionally, some custom errors have been added as reference for future extension.
-1
)-2
)-3
)-4
)-5
)Note:
PLAYER_ERR
versus the standardized MEDIA_ERR
to avoid confusion.true
)If the video element emits any of those errors, the corresponding error message will be displayed. You can override and add custom error codes by supplying options to the plugin:
player.errors({
errors: {
3: {
headline: 'This is an override for the generic MEDIA_ERR_DECODE',
message: 'This is a custom error message'
}
}
});
Or by calling player.errors.extend
after initializing the plugin:
player.errors();
player.errors.extend({
3: {
headline: 'This is an override for the generic MEDIA_ERR_DECODE',
message: 'This is a custom error message'
},
foo: {
headline: 'My custom "foo" error',
message: 'A custom "foo" error message.'
}
});
If you define custom error messages, you'll need to let Video.js know when to emit them yourself:
player.error({code: 'custom', dismiss: true});
If an error is emitted that doesn't have an associated key, a generic, catch-all message is displayed. You can override that text by supplying a message for the key unknown
.
On iPhones, default errors are not dismissible. The video element intercepts all user interaction so error message dialogs miss the tap events. If your video is busted anyways, you may not be that upset about this.
FAQs
A Video.js plugin for custom error reporting
We found that videojs-errors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 198 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Explore the security risks of using npm shrinkwrap, the potential for outdated dependencies, and best practices for mitigating these concerns in your projects.
Security News
Node.js is taking steps towards removing Corepack from its distribution, aiming for changes in the next major release.
Security News
OpenSSF has released a guide to help package repositories adopt Trusted Publishers, which enhances security by using short-lived identity tokens for authentication, reducing the risks associated with long-lived secrets.