diff --git a/.eslintrc.json b/.eslintrc.json index 63fefe4d..ae86f34f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,8 +5,12 @@ "browser": true, "es6": true }, - "globals": { "Plyr": false, "jQuery": false }, + "globals": { + "Plyr": false, + "jQuery": false + }, "rules": { + "import/no-cycle": 1, "no-const-assign": 1, "no-shadow": 0, "no-this-before-super": 1, @@ -21,19 +25,9 @@ "eqeqeq": [2, "always"], "one-var": [2, "never"], "comma-dangle": [2, "always-multiline"], - "no-restricted-globals": [ - "error", - { - "name": "event", - "message": "Use local parameter instead." - }, - { - "name": "error", - "message": "Use local parameter instead." - } - ], - "array-bracket-newline": [2, { "minItems": 2 }], - "array-element-newline": [2, { "minItems": 2 }] + "spaced-comment": [2, "always"], + "no-restricted-globals": 2, + "no-param-reassign": [2, { "props": false }] }, "parserOptions": { "sourceType": "module" diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 00000000..d4bebdfa --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: Report an issue or unexpected behaviour with Plyr +--- + + + +### Expected behaviour + +### Actual behaviour + +### Steps to reproduce + +### Environment + +- Browser: +- Version: +- Operating System: +- Version: + +### Console errors (if any) + +### Link to where the bug is happening + + diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md new file mode 100644 index 00000000..342ab0f0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -0,0 +1,10 @@ +--- +name: New feature +about: Request new functionality +--- + + diff --git a/.github/ISSUE_TEMPLATE/improvement.md b/.github/ISSUE_TEMPLATE/improvement.md new file mode 100644 index 00000000..de7e0576 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/improvement.md @@ -0,0 +1,10 @@ +--- +name: Improvement +about: Request a change that isn't a bug or new feature +--- + + diff --git a/.github/issue_template.md b/.github/issue_template.md index f503b944..54f4550b 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -1,17 +1,3 @@ - +PLEASE USE OUR SPECIFIC ISSUE TEMPLATES for bug reports, features and improvement suggestions. -### Expected behaviour - -### Actual behaviour - -### Environment - -- Browser: -- Version: -- Operating System: -- Version: - -### Steps to reproduce -- \ No newline at end of file +Our issue tracker is not for support questions. If you need help, follow our support instructions: https://github.com/sampotts/plyr/blob/master/contributing.md#support diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c4779d3c..f67d769f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,8 +1,8 @@ ### Link to related issue (if applicable) -### Sumary of proposed changes +### Summary of proposed changes -### Task list - -- [ ] Tested on [supported browsers](https://github.com/sampotts/plyr#browser-support) -- [ ] Gulp build completed \ No newline at end of file +### Checklist +- [ ] Use `develop` as the base branch +- [ ] Exclude the gulp build (`/dist` changes) from the PR +- [ ] Test on [supported browsers](https://github.com/sampotts/plyr#browser-support) diff --git a/.gitignore b/.gitignore index b17cd7c7..878292b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ node_modules .DS_Store -aws.json +credentials.json *.mp4 !dist/blank.mp4 index-*.html npm-debug.log +yarn-error.log +package-lock.json *.webm -/package-lock.json .idea/ - diff --git a/.npmignore b/.npmignore index afba951f..32ff635b 100644 --- a/.npmignore +++ b/.npmignore @@ -2,3 +2,10 @@ demo .github .vscode *.code-workspace +credentials.json +bundles.json +yarn.lock +package-lock.json +*.mp4 +*.webm +!dist/blank.mp4 \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index e1544230..cee783d4 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,7 +1,7 @@ { "useTabs": false, "tabWidth": 4, - "printWidth": 160, "singleQuote": true, - "trailingComma": "all" + "trailingComma": "all", + "printWidth": 120 } diff --git a/.stickler.yml b/.stickler.yml new file mode 100644 index 00000000..717ba28c --- /dev/null +++ b/.stickler.yml @@ -0,0 +1,5 @@ +linters: + eslint: +files: + ignore: + - 'node_modules/*' diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..3203fb95 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: lts/* + +script: +- bash .travis/prevent-base-master.sh +- bash .travis/omit-dist.sh +- npm run lint +- npm run build diff --git a/.travis/omit-dist.sh b/.travis/omit-dist.sh new file mode 100755 index 00000000..f107a6b9 --- /dev/null +++ b/.travis/omit-dist.sh @@ -0,0 +1,5 @@ +#!/bin/bash +if [ $TRAVIS_BRANCH == "develop" ] && $(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qE "^(demo/)?dist/"); then + echo 'Build output ("dist" and "demo/dist") not permitted in develop' >&2 + exit 1 +fi diff --git a/.travis/prevent-base-master.sh b/.travis/prevent-base-master.sh new file mode 100755 index 00000000..54536a66 --- /dev/null +++ b/.travis/prevent-base-master.sh @@ -0,0 +1,5 @@ +#!/bin/bash +if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ $TRAVIS_BRANCH == "master" ] && $(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -q "^src/"); then + echo 'The base branch for pull requests must be "develop"' >&2 + exit 1 +fi diff --git a/bower.json b/bower.json deleted file mode 100644 index 53c921b7..00000000 --- a/bower.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "plyr", - "description": "A simple HTML5 media player using custom controls", - "homepage": "http://plyr.io", - "keywords": [ - "Audio", - "Video", - "HTML5 Audio", - "HTML5 Video" - ], - "authors": [ - "Sam Potts " - ], - "dependencies": {}, - "main": [ - "dist/plyr.css", - "dist/plyr.js", - "dist/plyr.svg", - "src/less/plyr.less", - "src/scss/plyr.scss", - "src/js/plyr.js" - ], - "ignore": [ - "node_modules", - "bower_components", - ".gitignore" - ], - "repository": { - "type": "git", - "url": "git://github.com/sampotts/plyr.git" - }, - "license": "MIT" -} \ No newline at end of file diff --git a/changelog.md b/changelog.md index b4051587..cdbaba59 100644 --- a/changelog.md +++ b/changelog.md @@ -1,146 +1,317 @@ -# v3.3.6 +## v3.5.0 -* Vimeo fixes for mute state -* Vimeo ID fix (fixes #945) -* Use `
` for poster container -* Tooltip fixes for unicode languages (fixes #943) +- Preview seek/scrubbing thumbnails (thanks @jamesoflol) +- Fixes for proxy listeners (thanks @gurupras) +- Fix for buffer progress transition on WebKit (thanks @samuelgozi) +- Fix for error when mime type not specified (fixes #1274) +- Support YouTube noCookie (thanks Omar Khatib) +- Add Angular plugin reference (thanks @smnbbrv) +- Use `Math.trunc` instead of `parseInt` (thanks @taion) +- Many fixes for fullscreen in embedded players with non 16:9 screens or videos +- Added 'force' fallback option for fullscreen -# v3.3.5 +### v3.4.8 -* Removed `.load()` call as it breaks HLS (see #870) +- Calling customized controls function with proper arguments (thanks @a60814billy) -# v3.3.4 +### v3.4.7 -* Fix for controls sometimes not showing while video is playing -* Fixed logic for show home tab on option select +- Fix for Vimeo fullscreen with non native aspect ratios (fixes #854) -# v3.3.3 +### v3.4.6 -* Reverted change to show home tab on option select due to usability regression +- Added picture-in-picture support for Chrome 70+ +- Fixed issue with versioning the SVG sprite in the gulp build script -# v3.3.2 +### v3.4.5 -* Fix for ads running in audio -* Fix for setting poster on source change +- Added download button option to download either current source or a custom URL you specify in options +- Prevent immediate hiding of controls on mobile (thanks @jamesoflol) +- Don't hide controls on focusout event (fixes #1122) (thanks @jamesoflol) +- Fix HTML5 quality settings being incorrectly set in local storage (thanks @TechGuard) + +### v3.4.4 + +- Fixed issue with double binding for `click` and `touchstart` for `clickToPlay` option +- Improved "faux" fullscreen on iPhone X/XS phones with notch +- Babel 7 upgrade (which reduced the polyfilled build by ~10kb!) + +### v3.4.3 + +- Fixed issue with nodeList for custom playback controls + +### v3.4.2 + +- Fix play/pause button state + +### v3.4.1 + +- Bug fix for custom controls (fixes #1161) + +## v3.4.0 + +- Accessibility improvements (see #905) +- Improvements to the way the controls work on iOS +- Demo code clean up +- YouTube quality selection removed due to their poor support for it. As a result, the `qualityrequested` event has been removed +- Controls spacing improvements +- Fix for pressed property missing with custom controls (Fixes #1062) +- Fix #1153: Captions language fallback (thanks @friday) +- Fix for setting pressed property of undefined (Fixes #1102) + +### v3.3.23 + +- Add support for YouTube's hl param (thanks @renaudleo) +- Fix for captions positioning when no controls (thanks @friday and @mjfwebb) +- Fix #1108: Make sure youtube.onReady doesn't run twice (thanks @friday) +- Fix for WebKit repaint loop on the `` elements + +### v3.3.22 + +- Travis & CI improvements (thanks @friday) +- Add navigator.languages fallback for iOS 9 (thanks @friday) + +### v3.3.21 + +- Hide currentTime and progress for streams (thanks @mimse) +- Fixed condition check (thanks @mimse) +- Handle undefined this.player.elements.buttons.play (thanks @klassicd) +- Fix captions.toggle() if there is no toggle button (thanks @friday) + +### v3.3.20 + +- Fix for bug where controls wouldn't show on hover over YouTube video + +### v3.3.19 + +- Remove `pointer-events: none` on embed ` +
``` @@ -104,7 +115,12 @@ Much the same as YouTube above. ```html
- +
``` @@ -120,45 +136,51 @@ Include the `plyr.js` script before the closing `` tag and then in your J ```html - + ``` See [initialising](#initialising) for more information on advanced setups. -If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript, you can use the following: +You can use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript. There's 2 versions; one with and one without [polyfills](#polyfills). My recommendation would be to manage polyfills seperately as part of your application but to make life easier you can use the polyfilled build. ```html - + ``` -_Note_: Be sure to read the [polyfills](#polyfills) section below about browser compatibility +...or... + +```html + +``` ### CSS Include the `plyr.css` stylsheet into your `` ```html - + ``` If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following: ```html - + ``` ### SVG Sprite The SVG sprite is loaded automatically from our CDN (provided by [Fastly](https://www.fastly.com/)). To change this, see the [options](#options) below. For -reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.3.6/plyr.svg`. +reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.4.8/plyr.svg`. ## Ads -Plyr has partnered up with [vi.ai](http://vi.ai/publisher-video-monetization/?aid=plyrio) to offer monetization options for your videos. Getting setup is easy: +Plyr has partnered up with [vi.ai](https://vi.ai/publisher-video-monetization/?aid=plyrio) to offer monetization options for your videos. Getting setup is easy: -* [Sign up for a vi.ai account](http://vi.ai/publisher-video-monetization/?aid=plyrio) -* Grab your publisher ID from the code snippet -* Enable ads in the [config options](#options) and enter your publisher ID +- [Sign up for a vi.ai account](https://vi.ai/publisher-video-monetization/?aid=plyrio) +- Grab your publisher ID from the code snippet +- Enable ads in the [config options](#options) and enter your publisher ID Any questions regarding the ads can be sent straight to vi.ai and any issues with rendering raised through GitHub issues. @@ -167,7 +189,7 @@ Any questions regarding the ads can be sent straight to vi.ai and any issues wit ### SASS You can use `bundle.scss` file included in `/src` as part of your build and change variables to suit your design. The SASS require you to -use the [autoprefixer](https://www.npmjs.com/package/gulp-autoprefixer) plugin (you be should already!) as all declarations use the W3C definitions. +use the [autoprefixer](https://www.npmjs.com/package/gulp-autoprefixer) plugin (you should be already!) as all declarations use the W3C definitions. The HTML markup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__controls`. You can change the class hooks in the options to match any custom CSS you write. Check out the JavaScript source for more on this. @@ -205,10 +227,10 @@ WebVTT captions are supported. To add a caption track, check the HTML example ab You can specify a range of arguments for the constructor to use: -* A CSS string selector that's compatible with [`querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) -* A [`HTMLElement`](https://developer.mozilla.org/en/docs/Web/API/HTMLElement) -* A [`NodeList]`(https://developer.mozilla.org/en-US/docs/Web/API/NodeList) -* A [jQuery](https://jquery.com) object +- A CSS string selector that's compatible with [`querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) +- A [`HTMLElement`](https://developer.mozilla.org/en/docs/Web/API/HTMLElement) +- A [`NodeList`](https://developer.mozilla.org/en-US/docs/Web/API/NodeList) +- A [jQuery](https://jquery.com) object _Note_: If a `NodeList`, `Array`, or jQuery object are passed, the first element will be used for setup. To setup multiple players, see [setting up multiple players](#setting-up-multiple-players) below. @@ -267,46 +289,55 @@ In all cases, the constructor will return a Plyr object that can be used with th Options can be passed as an object to the constructor as above or as JSON in `data-plyr-config` attribute on each of your target elements: ```html - + ``` Note the single quotes encapsulating the JSON and double quotes on the object keys. Only string values need double quotes. -| Option | Type | Default | Description | -| -------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `enabled` | Boolean | `true` | Completely disable Plyr. This would allow you to do a User Agent check or similar to programmatically enable or disable Plyr for a certain UA. Example below. | -| `debug` | Boolean | `false` | Display debugging information in the console | -| `controls` | Array, Function or Element | `['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']` | If a function is passed, it is assumed your method will return either an element or HTML string for the controls. Three arguments will be passed to your function; `id` (the unique id for the player), `seektime` (the seektime step in seconds), and `title` (the media title). See [controls.md](controls.md) for more info on how the html needs to be structured. | -| `settings` | Array | `['captions', 'quality', 'speed', 'loop']` | If you're using the default controls are used then you can specify which settings to show in the menu | -| `i18n` | Object | See [defaults.js](/src/js/defaults.js) | Used for internationalization (i18n) of the text within the UI. | -| `loadSprite` | Boolean | `true` | Load the SVG sprite specified as the `iconUrl` option (if a URL). If `false`, it is assumed you are handling sprite loading yourself. | -| `iconUrl` | String | `null` | Specify a URL or path to the SVG sprite. See the [SVG section](#svg) for more info. | -| `iconPrefix` | String | `plyr` | Specify the id prefix for the icons used in the default controls (e.g. "plyr-play" would be "plyr"). This is to prevent clashes if you're using your own SVG sprite but with the default controls. Most people can ignore this option. | -| `blankUrl` | String | `https://cdn.plyr.io/static/blank.mp4` | Specify a URL or path to a blank video file used to properly cancel network requests. | -| `autoplay` | Boolean | `false` | Autoplay the media on load. This is generally advised against on UX grounds. It is also disabled by default in some browsers. If the `autoplay` attribute is present on a `