diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..c0775cb3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,36 @@ +## Description +Briefly describe the issue. +Include a [reduced test case](https://css-tricks.com/reduced-test-cases/). + +## Steps to reproduce +Explain in detail the exact steps necessary to reproduce the issue. + +1. +2. +3. + +## Results +### Expected +Please describe what you expected to see. + +### Actual +Please describe what actually happened. + +### 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? + +#### browsers +what browser are affected? + +#### OSes +what platforms (operating systems and devices) are affected? + +### plugins +are any videojs plugins being used on the page? If so, please list them below. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..dbb0a638 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,14 @@ +## Description +Please describe the change as necessary. +If it's a feature or enhancement please be as detailed as possible. +If it's a bug fix, please link the issue that it fixes or describe the bug in as much detail. + +## Specific Changes proposed +Please list the specific changes involved in this pull request. + +## Requirements Checklist +- [ ] Feature implemented / Bug fixed +- [ ] If necessary, more likely in a feature request than a bug fix + - [ ] Unit Tests updated or fixed + - [ ] Docs/guides updated +- [ ] Reviewed by Two Core Contributors diff --git a/.gitignore b/.gitignore index 0027a2f5..e8158cc8 100644 --- a/.gitignore +++ b/.gitignore @@ -25,11 +25,12 @@ npm-debug.log* bower_components/ node_modules/ -# Yeoman meta-data -.yo-rc.json - # Build-related directories dist/ -dist-test/ docs/api/ -es5/ +test/dist/ +.eslintcache +.yo-rc.json + +# Ignore Chinese clones for now. +lang/zh-Han*.json diff --git a/.npmignore b/.npmignore index c979e2f8..ea8c75d0 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,3 @@ -test/ -*~ +# Intentionally left blank, so that npm does not ignore anything by default, +# but relies on the package.json "files" array to explicitly define what ends +# up in the package. diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..518633e1 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/fermium diff --git a/.travis.yml b/.travis.yml index c0701691..ec0a6f3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,16 @@ sudo: false +dist: trusty language: node_js -node_js: - - 'node' - - '4.2' - - '0.12' - - '0.10' - -# Set up a virtual screen for Firefox. +# node version is specified using the .nvmrc file +before_install: + - npm install -g greenkeeper-lockfile@1 before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - -# Use the latest version of Firefox. + - greenkeeper-lockfile-update +after_script: + - greenkeeper-lockfile-upload addons: - firefox: 'latest' + firefox: latest + chrome: stable + diff --git a/CHANGELOG.md b/CHANGELOG.md index e456aab6..a648383a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,248 @@ -CHANGELOG -========= + +# [4.5.0](https://github.com/brightcove/videojs-errors/compare/v4.4.0...v4.5.0) (2021-05-04) -## HEAD (Unreleased) -* @mkody Fix typo in French translation (#39) -* @vdeshpande Close-button errors message accessible fix (#40) +### Features + +* add support for -1 timeout and backgroundTimeout values ([#206](https://github.com/brightcove/videojs-errors/issues/206)) ([cf0ea56](https://github.com/brightcove/videojs-errors/commit/cf0ea56)) + + +# [4.4.0](https://github.com/brightcove/videojs-errors/compare/v4.3.2...v4.4.0) (2021-04-13) + +### Features + +* Add backgroundTimeout option ([#198](https://github.com/brightcove/videojs-errors/issues/198)) ([d8d9efc](https://github.com/brightcove/videojs-errors/commit/d8d9efc)) +* allow turning off timeout by setting it to Infinity ([#204](https://github.com/brightcove/videojs-errors/issues/204)) ([b73f160](https://github.com/brightcove/videojs-errors/commit/b73f160)), closes [#134](https://github.com/brightcove/videojs-errors/issues/134) + +### Chores + +* don't run tests on version ([#205](https://github.com/brightcove/videojs-errors/issues/205)) ([c349883](https://github.com/brightcove/videojs-errors/commit/c349883)) + + +## [4.3.2](https://github.com/brightcove/videojs-errors/compare/v4.3.1...v4.3.2) (2020-03-13) + +### Bug Fixes + +* Trigger error handler on contenterror as well ([#191](https://github.com/brightcove/videojs-errors/issues/191)) ([723b2a6](https://github.com/brightcove/videojs-errors/commit/723b2a6)) + + +## [4.3.1](https://github.com/brightcove/videojs-errors/compare/v4.3.0...v4.3.1) (2020-02-08) + +### Bug Fixes + +* **lang:** Add missing Arabic translations ([#185](https://github.com/brightcove/videojs-errors/issues/185)) ([708b398](https://github.com/brightcove/videojs-errors/commit/708b398)) + +### Chores + +* **package:** Update development dependencies ([#186](https://github.com/brightcove/videojs-errors/issues/186)) ([98ce727](https://github.com/brightcove/videojs-errors/commit/98ce727)) + + +# [4.3.0](https://github.com/brightcove/videojs-errors/compare/v4.2.0...v4.3.0) (2019-08-06) + +### Features + +* Add class to error code line and make colon bold ([#164](https://github.com/brightcove/videojs-errors/issues/164)) ([7734d36](https://github.com/brightcove/videojs-errors/commit/7734d36)) + +### Bug Fixes + +* **lang:** Improved translations ([#165](https://github.com/brightcove/videojs-errors/issues/165)) ([5aa4877](https://github.com/brightcove/videojs-errors/commit/5aa4877)) +* **lang:** Update Chinese (Simplified) and Chinese (Traditional) and clone them to more correct language codes ([#176](https://github.com/brightcove/videojs-errors/issues/176)) ([568d41d](https://github.com/brightcove/videojs-errors/commit/568d41d)) + +### Chores + +* **package:** Update dependencies ([#172](https://github.com/brightcove/videojs-errors/issues/172)) ([90e8bbe](https://github.com/brightcove/videojs-errors/commit/90e8bbe)) +* **package:** Update development dependencies. ([#167](https://github.com/brightcove/videojs-errors/issues/167)) ([a0f4f96](https://github.com/brightcove/videojs-errors/commit/a0f4f96)) +* **package:** update lint-staged to version 8.1.0 ([#153](https://github.com/brightcove/videojs-errors/issues/153)) ([9322988](https://github.com/brightcove/videojs-errors/commit/9322988)) +* **package:** update npm-run-all/videojs-generator-verify for security ([d355dd5](https://github.com/brightcove/videojs-errors/commit/d355dd5)) +* **package:** update videojs-generate-karma-config to version 5.0.0 ([#152](https://github.com/brightcove/videojs-errors/issues/152)) ([7ffd25f](https://github.com/brightcove/videojs-errors/commit/7ffd25f)) +* **package:** update videojs-generate-karma-config to version 5.1.0 ([553b961](https://github.com/brightcove/videojs-errors/commit/553b961)) +* **package:** update videojs-generate-rollup-config to version 2.3.1 ([#154](https://github.com/brightcove/videojs-errors/issues/154)) ([f67d225](https://github.com/brightcove/videojs-errors/commit/f67d225)) +* **package:** update videojs-languages to version 2.0.0 ([#142](https://github.com/brightcove/videojs-errors/issues/142)) ([0299e75](https://github.com/brightcove/videojs-errors/commit/0299e75)) +* **package:** update videojs-standard to version 8.0.2 ([#155](https://github.com/brightcove/videojs-errors/issues/155)) ([cd0f8ca](https://github.com/brightcove/videojs-errors/commit/cd0f8ca)) + + +# [4.2.0](https://github.com/brightcove/videojs-errors/compare/v4.1.3...v4.2.0) (2018-10-04) + +### Bug Fixes + +* ignore progress events ([#143](https://github.com/brightcove/videojs-errors/issues/143)) ([348f670](https://github.com/brightcove/videojs-errors/commit/348f670)) +* Remove the postinstall script to prevent install issues ([#138](https://github.com/brightcove/videojs-errors/issues/138)) ([a2b2839](https://github.com/brightcove/videojs-errors/commit/a2b2839)) + +### Chores + +* update to generator-videojs-plugin[@7](https://github.com/7).2.0 ([1e77e8c](https://github.com/brightcove/videojs-errors/commit/1e77e8c)) +* **package:** update rollup to version 0.66.0 ([#140](https://github.com/brightcove/videojs-errors/issues/140)) ([459f9fb](https://github.com/brightcove/videojs-errors/commit/459f9fb)) + + +## [4.1.3](https://github.com/brightcove/videojs-errors/compare/v4.1.2...v4.1.3) (2018-08-23) + +### Chores + +* generator v7 ([#133](https://github.com/brightcove/videojs-errors/issues/133)) ([365e7b8](https://github.com/brightcove/videojs-errors/commit/365e7b8)) + + +## [4.1.2](https://github.com/brightcove/videojs-errors/compare/v4.1.1...v4.1.2) (2018-08-03) + +### Bug Fixes + +* babel the es dist, by updating the generator ([#127](https://github.com/brightcove/videojs-errors/issues/127)) ([983b83f](https://github.com/brightcove/videojs-errors/commit/983b83f)) + +### Chores + +* **package:** update dependencies, enable greenkeeper ([#126](https://github.com/brightcove/videojs-errors/issues/126)) ([7e95841](https://github.com/brightcove/videojs-errors/commit/7e95841)) + + +## [4.1.1](https://github.com/brightcove/videojs-errors/compare/v4.1.0...v4.1.1) (2018-07-05) + +### Chores + +* generator v6 ([#122](https://github.com/brightcove/videojs-errors/issues/122)) ([846d151](https://github.com/brightcove/videojs-errors/commit/846d151)) + + +# [4.1.0](https://github.com/brightcove/videojs-errors/compare/v4.0.0...v4.1.0) (2018-05-08) + +### Features + +* add standard VERSION property ([#120](https://github.com/brightcove/videojs-errors/issues/120)) ([c475d12](https://github.com/brightcove/videojs-errors/commit/c475d12)) + + +# [4.0.0](https://github.com/brightcove/videojs-errors/compare/v3.1.0...v4.0.0) (2018-05-02) + +### Features + +* Add timeout getter/setter ([#114](https://github.com/brightcove/videojs-errors/issues/114)) ([cb45723](https://github.com/brightcove/videojs-errors/commit/cb45723)) +* drop v5 support ([#119](https://github.com/brightcove/videojs-errors/issues/119)) ([f4440c1](https://github.com/brightcove/videojs-errors/commit/f4440c1)) + +### Bug Fixes + +* make the plugin ready for videojs 7 ([#117](https://github.com/brightcove/videojs-errors/issues/117)) ([8d96f2a](https://github.com/brightcove/videojs-errors/commit/8d96f2a)), closes [#116](https://github.com/brightcove/videojs-errors/issues/116) +* Restart timeout monitor if playing when reinitialised ([#113](https://github.com/brightcove/videojs-errors/issues/113)) ([af868ed](https://github.com/brightcove/videojs-errors/commit/af868ed)) --------------------- +### Documentation + +* **README:** Add usage npm/bundler usage ([#108](https://github.com/brightcove/videojs-errors/issues/108)) ([ec86764](https://github.com/brightcove/videojs-errors/commit/ec86764)) +* **README:** fix typo ([ec724b7](https://github.com/brightcove/videojs-errors/commit/ec724b7)) + + +### BREAKING CHANGES + +* drop v5 support. + + +# [3.1.0](https://github.com/brightcove/videojs-errors/compare/v1.0.0...v3.1.0) (2017-12-13) + +### Features + +* add custom error for flashls crossdomain errors ([#111](https://github.com/brightcove/videojs-errors/issues/111)) ([9d20fbd](https://github.com/brightcove/videojs-errors/commit/9d20fbd)) +* Add Czech translation ([#106](https://github.com/brightcove/videojs-errors/issues/106)) ([3cb9c1e](https://github.com/brightcove/videojs-errors/commit/3cb9c1e)) +* Add new custom errors and allow defining custom errors at runtime ([#90](https://github.com/brightcove/videojs-errors/issues/90)) ([4bd0cd9](https://github.com/brightcove/videojs-errors/commit/4bd0cd9)) +* Change codes of recently-added errors, allow type and code to be shared, and add `getAll()` method. ([#96](https://github.com/brightcove/videojs-errors/issues/96)) ([f39c0f6](https://github.com/brightcove/videojs-errors/commit/f39c0f6)) + +### Bug Fixes + +* Fix tests for video.js 6 ([#77](https://github.com/brightcove/videojs-errors/issues/77)) ([0d71164](https://github.com/brightcove/videojs-errors/commit/0d71164)) +* Resolve an issue where 'error' events triggered on the player during contrib-ads playback would not be recognized. ([#109](https://github.com/brightcove/videojs-errors/issues/109)) ([3b48430](https://github.com/brightcove/videojs-errors/commit/3b48430)) +* show spinner if player has stalled ([#104](https://github.com/brightcove/videojs-errors/issues/104)) ([a89513f](https://github.com/brightcove/videojs-errors/commit/a89513f)) + +### Chores + +* **package:** update browserify to version 13.3.0 ([#58](https://github.com/brightcove/videojs-errors/issues/58)) ([e61edb6](https://github.com/brightcove/videojs-errors/commit/e61edb6)) +* **package:** update karma to version 1.4.1 ([#69](https://github.com/brightcove/videojs-errors/issues/69)) ([7cd5e45](https://github.com/brightcove/videojs-errors/commit/7cd5e45)) +* **package:** update node-sass to version 4.5.0 ([#70](https://github.com/brightcove/videojs-errors/issues/70)) ([f7d7793](https://github.com/brightcove/videojs-errors/commit/f7d7793)) +* **package:** update npm-run-all to version 3.1.2 ([#48](https://github.com/brightcove/videojs-errors/issues/48)) ([0b3f13d](https://github.com/brightcove/videojs-errors/commit/0b3f13d)) +* **package:** update portscanner to version 2.1.1 ([#47](https://github.com/brightcove/videojs-errors/issues/47)) ([b83b979](https://github.com/brightcove/videojs-errors/commit/b83b979)) +* **package:** update shelljs to version 0.7.6 ([#60](https://github.com/brightcove/videojs-errors/issues/60)) ([9b966f6](https://github.com/brightcove/videojs-errors/commit/9b966f6)) +* Add translations for some new strings. ([#101](https://github.com/brightcove/videojs-errors/issues/101)) ([b3dc97a](https://github.com/brightcove/videojs-errors/commit/b3dc97a)) +* Update tooling using generator v5 prerelease. ([#99](https://github.com/brightcove/videojs-errors/issues/99)) ([b0e53e5](https://github.com/brightcove/videojs-errors/commit/b0e53e5)) +* update travis ([#71](https://github.com/brightcove/videojs-errors/issues/71)) ([86d7807](https://github.com/brightcove/videojs-errors/commit/86d7807)) + +### Code Refactoring + +* Updates for Video.js 6.0 compatibility. ([48ed04a](https://github.com/brightcove/videojs-errors/commit/48ed04a)) + + +### BREAKING CHANGES + +* Removed Bower support. +* Changed the codes of recently-added errors; so, they will no avoid collisions more reliably with 1.x implementations. + + +## [3.0.3](https://github.com/brightcove/videojs-errors/compare/v3.0.2...v3.0.3) (2017-09-06) + +### Features + +* Add Czech translation ([#106](https://github.com/brightcove/videojs-errors/issues/106)) ([3cb9c1e](https://github.com/brightcove/videojs-errors/commit/3cb9c1e)) + +### Bug Fixes + +* Resolve an issue where 'error' events triggered on the player during contrib-ads playback would not be recognized. ([#109](https://github.com/brightcove/videojs-errors/issues/109)) ([3b48430](https://github.com/brightcove/videojs-errors/commit/3b48430)) + + +## [3.0.2](https://github.com/brightcove/videojs-errors/compare/v3.0.1...v3.0.2) (2017-06-08) + +### Bug Fixes + +* show spinner if player has stalled ([#104](https://github.com/brightcove/videojs-errors/issues/104)) ([a89513f](https://github.com/brightcove/videojs-errors/commit/a89513f)) + + +## [3.0.1](https://github.com/brightcove/videojs-errors/compare/v3.0.0...v3.0.1) (2017-05-22) + +### Chores + +* Add translations for some new strings. ([#101](https://github.com/brightcove/videojs-errors/issues/101)) ([b3dc97a](https://github.com/brightcove/videojs-errors/commit/b3dc97a)) + + +# [3.0.0](https://github.com/brightcove/videojs-errors/compare/v1.0.0...v3.0.0) (2017-05-19) + +### Chores + +* Update tooling using generator v5 prerelease. ([#99](https://github.com/brightcove/videojs-errors/issues/99)) ([b0e53e5](https://github.com/brightcove/videojs-errors/commit/b0e53e5)) + +### BREAKING CHANGES + +* Removed Bower support. + +## 2.0.2 (2017-05-15) +* Fixed some tooling issues, including missing `dist/lang` files. + +## 2.0.1 (2017-05-15) +* Fixed mis-configured `package.json` fields. + +## 2.0.0 (2017-05-15) +* @misteroneill Move off of Spellbook for now and add pkg.module. ([#95](https://github.com/brightcove/videojs-errors/pull/95)) +* @misteroneill __BREAKING CHANGE__: Change codes of recently-added errors, allow type and code to be shared, and add `getAll()` method. ([#95](https://github.com/brightcove/videojs-errors/pull/95)) + +## 1.3.2 (2017-04-24) +* @forbesjo Added option to disable watching progress events ([#91](https://github.com/brightcove/videojs-errors/pull/91)) + +## 1.3.1 (2017-04-19) +* @misteroneill Fix size detection to account for players that have no configured dimensions ([#92](https://github.com/brightcove/videojs-errors/pull/92)) + +## 1.3.0 (2017-04-18) +* @misteroneill Add new custom errors and an `extend` method to customize errors at runtime ([#90](https://github.com/brightcove/videojs-errors/pull/90)) + +## 1.2.0 (2017-02-21) +* @gfviegas Add support for Portuguese ([#42](https://github.com/brightcove/videojs-errors/pull/42)) +* @bc-paul Allow errors to be non-dismissible ([#54](https://github.com/brightcove/videojs-errors/pull/54)) + +## v1.1.4 (2017-02-09) +* @misteroneill Remove deprecation warning about using videojs.plugin (#72) +* @BrandonOCasey Update Travis build to run w/ Video.js 5 and 6 (#71) + +## v1.1.3 (2017-01-27) +* @BrandonOCasey Updates for Video.js 6.0 compatibility. (#67) + +## v1.1.2 (2016-12-07) +* @forbesjo Error if Flash tech is unusable (#50) + +## v1.1.1 (2016-11-11) +* @mjneil Cleanup event bindings when reinitialized (#44) + +## v1.1.0 (2016-09-08) +* @vdeshpande Add in a user-friendly message for disabled Flash in IE (#41) + +## v1.0.5 (2016-08-10) +* @vdeshpande Close-button errors message accessible fix (#40) +* @mkody Fix typo in French translation (#39) ## v1.0.4 (2016-04-13) * Added listening for `'adtimeupdate'` ([#36](https://github.com/brightcove/videojs-errors/pull/36)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..7840f8ca --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# CONTRIBUTING + +We welcome contributions from everyone! + +## Getting Started + +Make sure you have Node.js 4.8 or higher and npm installed. + +1. Fork this repository and clone your fork +1. Install dependencies: `npm install` +1. Run a development server: `npm start` + +### Making Changes + +Refer to the [video.js plugin conventions][conventions] for more detail on best practices and tooling for video.js plugin authorship. + +When you've made your changes, push your commit(s) to your fork and issue a pull request against the original repository. + +### Running Tests + +Testing is a crucial part of any software project. For all but the most trivial changes (typos, etc) test cases are expected. Tests are run in actual browsers using [Karma][karma]. + +- In all available and supported browsers: `npm test` +- In a specific browser: `npm run test:chrome`, `npm run test:firefox`, etc. +- While development server is running (`npm start`), navigate to [`http://localhost:9999/test/`][local] + + +[karma]: http://karma-runner.github.io/ +[local]: http://localhost:9999/test/ +[conventions]: https://github.com/videojs/generator-videojs-plugin/blob/master/docs/conventions.md diff --git a/LICENSE b/LICENSE index e4e41deb..50c17f4d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2016 Brightcove, Inc. +Copyright Brightcove, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 11fd82e1..64b791cb 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ # videojs-errors [](https://travis-ci.org/brightcove/videojs-errors) +[](https://greenkeeper.io/) +[](http://slack.videojs.com) -A plugin that displays user-friendly messages when video.js encounters an error. +[](https://nodei.co/npm/videojs-errors/) -### Table of Contents +A plugin that displays user-friendly messages when Video.js encounters an error. + +Maintenance Status: Stable @@ -14,19 +18,43 @@ A plugin that displays user-friendly messages when video.js encounters an error. - [Localization](#localization) - [Supported Errors](#supported-errors) - [Custom Errors](#custom-errors) + - [Custom Errors without a Type](#custom-errors-without-a-type) + - [`getAll()`](#getall) + - [`timeout()`](#timeout) + - [`backgroundTimeout()`](#backgroundtimeout) - [Known Issues](#known-issues) ## Getting Started +**Importing via npm/Babel/Browserify/webpack** +```shell +npm install videojs-errors +``` + +Then import in your JavaScript +```js +import videojs from 'video.js'; +import 'videojs-errors'; +``` + +Installing the styles will depend on your build tool. +[Here's](http://brunch.io/docs/using-modules) 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: - +```html + +``` -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: +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: - +```html + +``` 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. @@ -34,15 +62,15 @@ If you're not a fan of the default styling, you can drop in your own stylesheet. 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: ```html - - + + ``` **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: +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`) @@ -52,34 +80,107 @@ Once you've initialized video.js, you can activate the errors plugin. The plugin ### Custom Errors -Additionally, 2 custom error scenarios have been added as reference for future extension. +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 +- FLASHLS_ERR_CROSS_DOMAIN -NOTES: +**Note:** -- Custom error definitions should be limited to the initCustomErrorConditions routine for encapsulation. -- Custom errors should reference a code value of a negative integer. -- Custom errors should reference a type beginning with 'PLAYER_ERR' versus the standardized 'MEDIA_ERR' to avoid confusion. +- 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: - video.errors({ - errors: { - 3: { - headline: 'This is an override for the generic MEDIA_ERR_DECODE', - message: 'This is a custom error message' - } - } - }); +```js +player.errors({ + errors: { + 3: { + headline: 'This is an override for the generic MEDIA_ERR_DECODE', + message: 'This is a custom error message' + } + } +}); +``` -If you define custom error messages, you'll need to let video.js know when to emit them yourself: +Or by calling `player.errors.extend` _after_ initializing the plugin: + +```js +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' + } +}); +``` - video.error({code: 'custom'}); +If you define custom error messages, you'll need to let Video.js know when to emit them yourself: + +```js +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: + +```js +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: + +```js +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: + +```js +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](#timeout) except the default value is 5 minutes. + ## Known Issues -On iPhones, the video element intercepts all user interaction so error message dialogs miss the tap events and don't dismiss themselves. If your video is busted anyways, you may not be that upset about this. +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. diff --git a/bower.json b/bower.json deleted file mode 100644 index 18009f66..00000000 --- a/bower.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "videojs-errors", - "author": "Brightcove, Inc.", - "license": "Apache-2.0", - "main": [ - "dist/videojs-errors.min.js" - ], - "keywords": [ - "videojs", - "videojs-plugin" - ] -} diff --git a/index.html b/index.html index 5123faf9..474981ac 100644 --- a/index.html +++ b/index.html @@ -3,14 +3,15 @@