npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

videojs-errors

v6.2.0

Published

A Video.js plugin for custom error reporting

Downloads

4,342

Maintainers

sachin-brightcovesachin-brightcovealexey.kremsaalexey.kremsamelinda.darvasimelinda.darvasijose.luis.sanchezjose.luis.sanchezpedro-cruzpedro-cruzgabor.kiacz.brightcovegabor.kiacz.brightcoveadambertalanbcadambertalanbcmiklospocsaji_bcmiklospocsaji_bcmaraizamaraizaskarukamannaskarukamannaaviel_resnickaviel_resnicknorma.gonzaleznorma.gonzalezjvaldez1jvaldez1fsalazarbcfsalazarbccognatusbgscognatusbgsmbalasubramaniammbalasubramaniamssahssahdgonzalez89dgonzalez89areis10areis10vmnavarrovmnavarroalfredo-reyesalfredo-reyesjterranovajterranovajfloresbcjfloresbcmlopez.bmlopez.bttabrilla-bcttabrilla-bcmsivallsmsivallssstevanussstevanusrwbarber2rwbarber2rwingerrwingerbcc-bfranklinbcc-bfranklinapenigalapatiapenigalapatilmaultsbylmaultsbysravan.pbrsravan.pbrijunaidfijunaidfmgoncalvesmgoncalvesmfregozomfregozoareveloarevelomadhu_gmadhu_ghugocjimhugocjimdaniel_camposdaniel_camposkevin.schickkevin.schickm.morrisonm.morrisonuomaruomarabarstowbcabarstowbcsbarathansbarathankpandiyarajankpandiyarajanimoronesimoroneswalterseymourbcwalterseymourbcddashkevichddashkevichalbertogomezalbertogomezgestrada-brgestrada-bramillerbrightcoveamillerbrightcovelvohralvohramcho-bcmcho-bcawaldronawaldrondawnpackodawnpackoldominguezldominguezbc-srimron-soutterbc-srimron-soutterrsilva_brightcoversilva_brightcovejoeyleshjoeyleshlmelchorx1lmelchorx1juan-sanchezjuan-sanchezeolveraeolveracloewer_bccloewer_bccarredondocarredondobrianhsubrianhsuniklagbrightcoveniklagbrightcovetsraveling_bctsraveling_bcbcbcliffordbcbcliffordbc-acgarciabc-acgarciaadavila1adavila1kreynoldskreynoldsbgs-devopsbgs-devopsalbinjohnsonalbinjohnsonrtezerartezerabcmneilbcmneilrandresfrandresfv.kozlov_bcv.kozlov_bcnagendra_mnagendra_mmichaelmccarthybcmichaelmccarthybcponeill-bcovponeill-bcovmdeltorobcovmdeltorobcovjmohneycovejmohneycoveinbc01inbc01aperezbrightcoveaperezbrightcoveireyes94ireyes94brightcove-adminbrightcove-admintedktedkabradley-brightcoveabradley-brightcovebc-alivebc-alivelasanchezclasanchezcmarguinbcmarguinbcbrightcove-userbrightcove-userkmasonkmasoncbarstowcbarstowhikehhikehmyerramallamyerramallapdiaspdiasjwhisenantjwhisenantebertaudebertauddsalnikovdsalnikovsharanya.muruganandamsharanya.muruganandamxgarcia_npmxgarcia_npmjguerrajguerrarjunerjunejonbwalshjonbwalshkhaiphamkhaiphamwswanbeckwswanbeckgastafurovgastafurovadalwaniadalwaniekelson-bcoveekelson-bcovesysengsysengmcarreiromcarreirohwoodburyhwoodburyjblakerjblakerbcmauleonbcmauleonpaco_oblea_bcpaco_oblea_bcjsepulvedajsepulvedabiswaranjanbiswaranjanbarroyobarroyobmartinezbmartinezbc-jcarlsonbc-jcarlsoneledezmaeledezmajcuetojcuetoerodrigueserodriguespsousapsousamarcogaraymarcogarayjavibrightjavibrightbcpsalasbcpsalasetobinetobinackbabeackbabecvillasenorcvillasenoromartinezomartinezmgonzalez_bcmgonzalez_bcpdohertybcovpdohertybcovmuthukumar.bcmuthukumar.bcbzizmondbzizmondjmpmacedojmpmacedoscorreiascorreialescorciolescorciocavieiracavieiraarunjeyaprasadarunjeyaprasadbvilvanathanbvilvanathananand.gangadharananand.gangadharanrociosantosrociosantosagarciabcovagarciabcovattinderattinderlauralopezlauralopezskumar85skumar85hrodriguez2hrodriguez2jasilvaantoniojasilvaantoniopalvarezbcpalvarezbcericramosericramoscarlosabajocarlosabajoingrid.s.cruzingrid.s.cruzluis_fernando_lopez_ruizluis_fernando_lopez_ruizvishal64vishal64tresa.bajitresa.bajiluis.garcia.brightcoveluis.garcia.brightcoverodrigofdzrodrigofdzpgutierrezgilpgutierrezgilharish17harish17jjeyaprakashjjeyaprakashrrajendran1698rrajendran1698jlomelijlomelisjimenezsjimenezrwenger_brightcoverwenger_brightcoverujordanrujordanstuartmhstuartmhjherrerabcovjherrerabcovmshiwalmshiwalptamizhptamizhakamalakkannanakamalakkannanroman-bcroman-bctnwannatnwannabsahlas.npmbsahlas.npmdherrera1109dherrera1109hswaminathanhswaminathanechengbcechengbcsbarrettbcsbarrettbcphalephalevideojs-uservideojs-userusmanonazimusmanonazimmmccluremmccluremisteroneillmisteroneillmisterbenmisterbenldayldayimbcmdthimbcmdthheffheffgkatsevgkatsevgesingergesingeresskesskdmlapdmlapbrandonocaseybrandonocaseyabarstowabarstowincomplincomplbclwhitakerbclwhitakerseniorflexdeveloperseniorflexdeveloperforbesjoforbesjotomruggstomruggsmjneilmjneil

Readme

videojs-errors

Build Status Greenkeeper badge Slack Status

NPM

A plugin that displays user-friendly messages when Video.js encounters an error.

Maintenance Status: Stable

Getting Started

Importing via npm/Babel/Browserify/webpack

npm install videojs-errors

Then 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.

Localization

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'.

Supported Errors

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:

  • MEDIA_ERR_ABORTED (numeric value 1)
  • MEDIA_ERR_NETWORK (numeric value 2)
  • MEDIA_ERR_DECODE (numeric value 3)
  • MEDIA_ERR_SRC_NOT_SUPPORTED (numeric value 4)
  • MEDIA_ERR_ENCRYPTED (numeric value 5)

Custom Errors

Additionally, some custom errors have been added as reference for future extension.

  • MEDIA_ERR_UNKNOWN (value 'unknown')
  • PLAYER_ERR_NO_SRC (numeric value -1)
  • PLAYER_ERR_TIMEOUT (numeric value -2)
  • PLAYER_ERR_DOMAIN_RESTRICTED
  • PLAYER_ERR_IP_RESTRICTED
  • PLAYER_ERR_GEO_RESTRICTED

Note:

  • Custom errors should reference a code value of a string.
    • Two of the provided errors use negative numbers for historical reasons, but alpha-numeric/descriptive strings are less likely to cause collision issues.
  • Custom errors should have a type beginning with PLAYER_ERR_ versus the standardized MEDIA_ERR to avoid confusion.
  • Custom errors can be chosen to be dismissible (boolean value 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.

Custom Errors without a Type

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.

Known Issues

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.