Coder Social home page Coder Social logo

videojs / videojs-errors Goto Github PK

View Code? Open in Web Editor NEW
86.0 47.0 29.0 2.75 MB

A video.js plugin that displays error messages to video viewers.

License: Other

JavaScript 87.58% HTML 4.56% CSS 7.86%
videojs errors javascript video-element video html5

videojs-errors's Introduction

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.

videojs-errors's People

Contributors

alex-barstow avatar axten avatar bc-paul avatar bcbclifford avatar bcdmlap avatar bclwhitaker avatar brandonocasey avatar dependabot[bot] avatar dmlap avatar forbesjo avatar gfviegas avatar gkatsev avatar greenkeeper[bot] avatar greenkeeperio-bot avatar harisha-swaminathan avatar imbcmdth avatar incompl avatar kchang-brightcove avatar mister-ben avatar misteroneill avatar mjneil avatar mkody avatar roman-bc-dev avatar tomjohnson916 avatar tomruggs avatar vasimi avatar vdeshpande avatar wetoolaguer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

videojs-errors's Issues

videojs-errors does not work with npm and video.js 6

Description

The videojs-errors plugin is not registered correctly when using with videojs 6 and npm.
The reason is the package json: "video.js": "^5.19.2".

This leads npm to download an own videojs dependency for this plugin that is be used.
So videojs 5 gets imported too and videojs 6 doesn't know the errors plugin.

Steps to reproduce

just try:

import videojs from 'video.js';
import errors from 'videojs-errors';

videojs.getPlugin('errors')  //undefined

Results

Expected

plugin works properly.

Actual

videojs-errors is not registered as a plugin and videojs 5 get additionally added to bundle.

versions

videojs: 6.8.0
videojs-error: 3.1.0

initializing with video js options is not working

Description

plugin initializing with video js options is not working.

Steps to reproduce

just do:

import videojs from 'video.js';
import 'videojs-errors';

const options = {
    plugins: {
        errors: { 
            errors: {
                FOO: {
                    headline: 'headline',
                    message: 'This is a custom error message'
                }
            }
        }
    }
};

const player = videojs(element, options, () => {

    setTimeout(() => {
        console.log(player.errors.getAll()); // contains FOO error

        player.error({code: 'FOO'}); // empty error screen appears
        
    },2000);
});


Results

Expected

custom error should be visible

Actual

error screen appears empty (except a white X)

Error output

Additional Information

videojs

6.8

errors plugin

4.1

Disabling default error message(s)

I'm working on a plugin that allows you to record audio/video using video.js. When the user requests access to the system's microphone using getUserMedia there's a chance he denies access and this throws an error message. I'd like to use your plugin for this but running into a problem;

when loading the plugin it immediately shows a PLAYER_ERR_NO_SRC error. This is expected because you're working without a source when recording locally. Is there a way to disable this error message (or all of them)?

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 1.18.0 to 1.19.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 6 commits.

  • 9af119d 1.19.0
  • b3f361c Update changelog
  • 456f4d2 Avoid variable from empty module name be empty (#3026)
  • 17eaa43 Use id of last module in chunk as name base for auto-generated chunks (#3025)
  • 871bfa0 Switch to a code-splitting build and update dependencies (#3020)
  • 2443783 Unified file emission api (#2999)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of conventional-changelog-cli is breaking the build 🚨

The devDependency conventional-changelog-cli was updated from 2.0.5 to 2.0.7.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

conventional-changelog-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

files

Hello,

I m interested to use this plugin but I don't know how to built the error.css and error.js files.

Could it be possible to ship the ready made files in the zip?

thanks

HLS Live Playback not satisfying timeout and pauses after 45 seconds.

Description

Briefly describe the issue.
When we cast our stream (chromecast).
If we have included the errors plugin, the timeout is not satisfied for live HLS content.
The plugin is calling triggerReady(). Thats call seems to cause the problem if we pause on a break before that, the timeout is not started.

Looking to know how I could prevent thet timeout, reset it, or satisfy it.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. Include this plugin
  2. include this plugin and view issue: silvermine/videojs-chromecast#28

Results

Expected

Video cast as normal: 'vjs-is-waiting' or stall to stop.

Actual

Videois casts and pauses after 45 seconds.

Error output

If there are any errors at all, please include them here.

Additional Information

Please include any additional information necessary here. Including the following:

versions

videojs

what version of videojs does this occur with?
"version": "6.12.1",

Can reproduce here: https://dev.pac-12.com/live/pac-12-live-press-conferences

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 1.9.2 to 1.9.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v1.9.3

2019-04-10

Bug Fixes

  • Simplify return expressions that are evaluated before the surrounding function is bound (#2803)

Pull Requests

  • #2803: Handle out-of-order binding of identifiers to improve tree-shaking (@lukastaegert)
Commits

The new version differs by 3 commits.

  • 516a06d 1.9.3
  • a5526ea Update changelog
  • c3d73ff Handle out-of-order binding of identifiers to improve tree-shaking (#2803)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 1.27.6 to 1.27.7.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v1.27.7

2019-12-01

Bug Fixes

  • Fix a scenario where a reassignments to computed properties were not tracked (#3267)

Pull Requests

Commits

The new version differs by 4 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Missing files

hi

<script src='videojs.errors.js'></script>

and the corresponding css file arent included in the master.

v4.1.1 Breaks webpack uglifier

Description

Briefly describe the issue.
The newest release throws a webpack error. The result is a non uglified js file so its much larger in file size.

ERROR in p_videojs.js from UglifyJs
Unexpected token: name (monitor) [p_videojs.js:49757,6]

Steps to reproduce

"./node_modules/.bin/webpack -p --config webpack.config.js"

the -p flag is important. Make sure not using any extra uglifer plugin. See package.json below.

"devDependencies": {
    "babel-core": "^6.24.1",
    "babel-loader": "^6.4.1",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-object-assign": "^6.22.0",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-plugin-transform-react-inline-elements": "^6.22.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-es2016": "^6.24.1",
    "babel-preset-react": "^6.22.0",
    "classnames": "^2.2.5",
    "css-loader": "^0.28.4",
    "extract-text-webpack-plugin": "^2.1.2",
    "node-sass": "^4.7.2",
    "promise-polyfill": "6.0.2",
    "sass-loader": "^6.0.6",
    "style-loader": "^0.18.2",
    "url-loader": "^0.6.2",
    "webpack": "^3.10.0"
  },
  "dependencies": {
    "can-autoplay": "^3.0.0",
    "es6-promise": "^4.1.1",
    "global": "^4.3.2",
    "ie-array-find-polyfill": "^1.1.0",
    "is-empty": "^1.2.0",
    "query-string": "^5.1.0",
    "react": "^15.4.2",
    "react-dom": "^15.6.2",
    "video.js": "^6.9.0",
    "videojs-contrib-ads": "^6.2.0",
    "videojs-contrib-hls": "^5.14.1",
    "videojs-errors": "4.1.0",
    "videojs-flash": "^2.1.0",
    "videojs-hotkeys": "^0.2.21",
    "videojs-ima": "^1.3.0"
  }

Webpack config:

var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  context: __dirname + "/src",
  entry: "./index.js",
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader?presets[]=es2016,presets[]=react'
      },
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract({
          fallback: 'style-loader', // The backup style loader
          use: 'css-loader?sourceMap!sass-loader?sourceMap'
        })
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'url-loader'
      }
    ],
  },
  output: {
    filename: "p_videojs.js",
    path: __dirname + "/dist",
  },
  plugins: [
    new ExtractTextPlugin('p_videojs.css')
  ],
}

babel.rc

{
  "compact": true,
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["last 2 versions", "safari >= 7"]
      }
    }]
  ],
  "plugins": [
    "transform-object-assign",
    "transform-class-properties",
    "transform-react-inline-elements",
    "transform-object-rest-spread"
  ]
}

Results

Expected

Would compile and uglifiy as normal.

Actual

Throws error.

v4.1.0 works fine.

Cannot set error message for FLASH: rtmpconnectfailure

I'm trying to set custom message for this video.js error and have no success:
VIDEOJS: ERROR: (CODE:0 MEDIA_ERR_CUSTOM) FLASH: rtmpconnectfailure

video.errors({
    errors: {
        0: {
            headline: 'This is an override for the generic MEDIA_ERR_DECODE',
            message: 'This is a custom error message'
        }
    }
});

es6 import of a language file does not work

Description

if I try to import a language file I got ReferenceError: videojs is not defined

so any lang file should have an import statement befor videojs to fix this.
besides that, a work around could be to provide the pure json files in videojs build.
this also would be great to extend a language during project build.

Steps to reproduce

just do

import videojs from 'video.js';
import 'videojs-errors';

import 'videojs-errors/dist/lang/de';

Results

Expected

should work as expected

Actual

it breaks

Additional Information

videojs: 6.8.0

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 0.67.3 to 0.67.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Missing js/css files v3.0.3

I would like to use your plugin (v3.0.3) but after downloading the zip and opening it, I could not find the js/css files to include in the page. How can I get the latest files of this great plugin?

PLAYER_ERR_GEO_RESTRICTED

Description

Hello!
My videos that use geoblock return a 403 error, however, with 'mediaerror' it always gets in error 4. I would like it to get into the PLAYER_ERR_GEO_RESTRICTED error. How could I do that?

versions

videojs

v7.7.5

plugins

videojs-errors
v4.3.2

An in-range update of karma is breaking the build 🚨

The devDependency karma was updated from 3.1.1 to 3.1.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

karma is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v3.1.2

Bug Fixes

Features

Commits

The new version differs by 11 commits.

  • 7d4d347 chore: release v3.1.2
  • 5077c18 chore: update contributors
  • fb05fb1 fix(server): use flatted for json.stringify (#3220)
  • 2682bff feat(docs): callout the key debug strategies. (#3219)
  • 4e87902 fix(changelog): remove release which does not exist (#3214)
  • 30ff73b fix(browser): report errors to console during singleRun=false (#3209)
  • 5334d1a fix(file-list): do not preprocess up-to-date files (#3196)
  • dc5f5de fix(deps): upgrade sinon-chai 2.x -> 3.x (#3207)
  • d38f344 fix(package): bump lodash version (#3203)
  • ffb41f9 refactor(browser): log state transitions in debug (#3202)
  • 240209f fix(dep): Bump useragent to fix HeadlessChrome version (#3201)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

ES6 Syntax not being transpiled in .es.js

Description

v4.1.1 is not transpiling es6 syntax correctly. Specifically, arrow functions are not being transpiled. Not an issue in v4.1.0

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. git clone [email protected]:brightcove/videojs-errors.git

  2. cd videojs-errors

  3. npm i

  4. npm run build

  5. grep "=>" ./dist/videojs-errors.es.js

  6. Observe that there are remaining arrow functions.

  7. git fetch --all --tags --prune

  8. git checkout tags/v4.1.0 -b v410

  9. npm i

  10. npm build

  11. grep "=>" ./dist/videojs-errors.es.js

  12. Observe that there no are remaining arrow functions.

Results

Expected

Expected to see es5 friendly syntax.

Actual

Expected to see es6 syntax, specifically arrow functions.

Error output

If there are any errors at all, please include them here.

Additional Information

Please include any additional information necessary here. Including the following:

versions

videojs

^6.8.0 || ^7.0.0

browsers

what browser are affected?
cli only.

OSes

what platforms (operating systems and devices) are affected?
OSX 10.13.3

plugins

are any videojs plugins being used on the page? If so, please list them below.
No.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.