package
A Video.js plugin for custom error reporting
npm install videojs-errorsGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
A plugin that displays user-friendly messages when Video.js encounters an error.
Maintenance Status: Stable
Importing via npm/Babel/Browserify/webpack
npm install videojs-errorsThen import in your JavaScript
import videojs from 'video.js';
import 'videojs-errors';Installing the styles will depend on your build tool. Here's an example of including styles with brunch. See Including Module's styles section.
Importing via script tag
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.
'unknown')-1)-2)Note:
type beginning with 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.',
type: 'PLAYER_ERR_FOO'
}
});If you define custom error messages, you'll need to let Video.js know when to emit them yourself:
player.error({code: 'foo', 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.
As of v2.0.0, custom errors can be defined without a code. In these cases, the key provided will be used as the code. For example, the custom foo error above could be:
player.errors.extend({
PLAYER_ERR_FOO: {
headline: 'My custom "foo" error',
message: 'A custom "foo" error message.'
}
});The difference here being that one would then trigger it via:
player.error({code: 'PLAYER_ERR_FOO'});getAll()After the errors plugin has been initialized on a player, a getAll() method is available on the errors() plugin method. This function returns an object with all the errors the plugin currently understands:
player.errors();
var errors = player.errors.getAll();
console.log(errors['1'].type); // "MEDIA_ERR_ABORTED"timeout()After the errors plugin has been initialized on a player, a timeout() method is available on the errors() plugin method.
A new timeout may be set by passing a timeout in milliseconds, e.g. player.errors.timeout(5 * 1000).
Setting the timeout to Infinity or -1 will turn off this check.
If no argument is passed, the current timeout value is returned.
backgroundTimeout()This functions exactly like timeout except the default value is 5 minutes.
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.
brightcove-user
npm-user@brightcove.com
paco_oblea_bc
foblea@brightcove.com
bmartinez
bmartinez@brightcove.com
ackbabe
backer@brightcove.com
omartinez
omartinez@brightcove.com
mgonzalez_bc
mgonzalez@brightcove.com
bvilvanathan
bvilvanathan@brightcove.com
agarciabcov
agarcia@brightcove.com
palvarezbc
palvarez@brightcove.com
ericramos
eramos@brightcove.com
carlosabajo
cbajo@brightcove.com
luis.garcia.brightcove
lfgarcia@brightcove.com
stuartmh
shicks@brightcove.com
mshiwal
mshiwal@brightcove.com
tnwanna
tnwanna@brightcove.com
sbarrettbc
sbarrett@brightcove.com
bc-srimron-soutter
srimron-soutter@brightcove.com
bgs-devops
bgs-devops@brightcove.com
actis92
la@bendingspoons.com
xgarcia_npm
xgarcia+npm@brightcove.com
fmahmoud-bgs
fmahmoud@brightcove.com
imorones
imorones@brightcove.com
brightcoveit
bc-it@brightcove.com
daniel_campos
dcampos@brightcove.com
bc-juanm
jmontero@brightcove.com
cognatusbgs
dmartinez@brightcove.com
apenigalapati
apenigalapati@brightcove.com
ijunaidf
ijunaid@brightcove.com
lmaultsby
lmaultsby@brightcove.com
bcc-bfranklin
bfranklin@brightcove.com
giuc-bsp
giuc-bsp@brightcove.com
sfraga
sfraga@brightcove.com
anrs-bsp
anrs@bendingspoons.com
alessandrofumi
afum-bsp@brightcove.com
ague01
ague-bsp@brightcove.com
bc-jcuevas
jcuevas@brightcove.com
mpao-bsp
mpao-bsp@brightcove.com
rkraybill
rkraybill@brightcove.com
tcarrillo
tcarrillo@brightcove.com
rvanoni
rvanoni@brightcove.com
javierflx
jfelix@brightcove.com
plun-bsp
plun-bsp@brightcove.com
waku_matsuo
wmatsuo@brightcove.com
ashabc
asriperambudur@brightcove.com
bcnnagasawa
nnagasawa@brightcove.com
bc-david-aguilar
dhardy@brightcove.com
krishdesai6
kdesai@brightcove.com
dgonzalezarbelo
dgon@bendingspoons.com
bcbrendo
bclay@brightcove.com
mchang39
mchang@brightcove.com
carlbrightcove
crutman@brightcove.com
pfbcove
pfiorito@brightcove.com
amrtbc
amartinez@brightcove.com
diego08802
dgar-bsp@brightcove.com
rmurata
rmurata@brightcove.com
fanobrega
fanobrega@brightcove.com
brightcove-assistant
brightcove-assistant@brightcove.com
mvaz-bsp
mvaz@bendingspoons.com
alpe-bsp-bcove
alpe-bsp@brightcove.com
mylofarman
efar@bendingspoons.com
bclgu
liguaus@gmail.com
fpartida
fpartida@brightcove.com
dan4everyone
dn.cnf@icloud.com
ld-bsp
ld-bsp@brightcove.com
sapa-bsp
sapa-bsp@brightcove.com
alik-brightcove
alik-bsp@brightcove.com
kreynolds
kreynolds@brightcove.com
bcdjones
djones@brightcove.com
awahabbc
awahab@brightcove.com
alet-bsp
alet-bsp@brightcove.com
dc-bsp
dc-bsp@brightcove.com
fabioluccioletti
fabl-bsp@brightcove.com
lucr-bsp
lucr-bsp@brightcove.com
eld-bsp
eld-bsp@brightcove.com
etri-bsp
etri-bsp@brightcove.com
rbalajee
rbalajee@brightcove.com
dvidaurri
dvidaurri@brightcove.com
gcastanheiro-bc
gcastanheiro@brightcove.com
cpillsburymux
cpillsbury@mux.com
abarstow
alexander.barstow@gmail.com
awaldron
awaldron@brightcove.com
brandonocasey
brandonocasey@gmail.com
essk
sarah@teaandbiscuits.net
gesinger
gesinger@gmail.com
gkatsev
me@gkatsev.com
heff
npm@heff.me
hswaminathan
hswaminathan@brightcove.com
imbcmdth
jon.carlos.rivera@gmail.com
lday
ldayananda@brightcove.com
mmcclure
npm@htbx.net
usmanonazim
usmanonazim@gmail.com
videojs-user
videojs@gkatsev.com
ddashkevich
ddashkevich@brightcove.com
phale
phale@brightcove.com
decepulis
de.cepulis@gmail.com
luwes
me@wesleyluyten.com
incompl
gsmith@incompl.com
bclwhitaker
lwhitaker@brightcove.com
seniorflexdeveloper
seniorflexdeveloper@gmail.com
misteroneill
pgoneill@gmail.com
dmlap
dlapalomento@gmail.com
forbesjo
joseph.a.forbes@gmail.com
tomruggs
truggles@brightcove.com
mjneil
mneilweb@gmail.com