diff options
Diffstat (limited to 'readme.md')
-rw-r--r-- | readme.md | 42 |
1 files changed, 31 insertions, 11 deletions
@@ -80,7 +80,7 @@ If you want to use our CDN, you can use the following: You can also access the `sprite.svg` file at `https://cdn.plyr.io/1.5.21/sprite.svg`. ### CSS & Styling -If you want to use the default css, add the `plyr.css` file from `/dist` into your head, or even better use `plyr.less` or `plyr.sass` file included in `/src` in your build to save a request. +If you want to use the default css, add the `plyr.css` file from `/dist` into your head, or even better use `plyr.less` or `plyr.scss` file included in `/src` in your build to save a request. ```html <link rel="stylesheet" href="dist/plyr.css"> @@ -89,7 +89,18 @@ If you want to use the default css, add the `plyr.css` file from `/dist` into yo The default setup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__controls`. You can change the class hooks in the options. Check out the source for more on this. ### SVG -The SVG sprite for the controls icons is loaded in by AJAX to help with performance. This is best added before the closing `</body>`, before any other scripts. +The SVG sprite for the controls icons can be loaded two ways: +- By passing the path to the sprite as the `iconUrl` option; or +- Using AJAX, injecting the sprite into a hidden div. + +#### Using the `iconUrl` option +This method requires the SVG sprite to be hosted on the *same domain* as your page hosting the player. Currently no browser supports cross origin SVG sprites due to XSS issues. Fingers crossed this will come soon though. An example value for this option would be: +``` +/path/to/sprite.svg +``` + +#### Using AJAX +Using AJAX means you can load the sprite from a different origin. Avoiding the issues above. This is an example script to load an SVG sprite best added before the closing `</body>`, before any other scripts. ```html <script> @@ -104,7 +115,7 @@ The SVG sprite for the controls icons is loaded in by AJAX to help with performa c.innerHTML = a.responseText; b.insertBefore(c, b.childNodes[0]); }; -})(document, 'path/to/sprite.svg'); +})(document, 'https://cdn.plyr.io/1.5.21/sprite.svg'); </script> ``` @@ -207,6 +218,9 @@ Passing just the options object: plyr.setup(options); ``` +#### RangeTouch +Some touch browsers (particularly Mobile Safari on iOS) seem to have issues with `<input type="range">` elements whereby touching the track to set the value doesn't work and sliding the thumb can be tricky. To combat this, I've created [RangeTouch](https://rangetouch.com) which I'd recommend including in your solution. It's a tiny script with a nice benefit for users on touch devices. + #### Options Options must be passed as an object to the `setup()` method as above or as JSON in `data-plyr` attribute on each of your target elements (e.g. data-plyr='{ title: "testing" }') - note the single quotes encapsulating the JSON. @@ -252,6 +266,12 @@ Options must be passed as an object to the `setup()` method as above or as JSON <td>Specify the id prefix for the icons used in the default controls (e.g. "icon-play" would be "icon"). This is to prevent clashes if you're using your own SVG defs file but with the default controls. Most people can ignore this option.</td> </tr> <tr> + <td><code>iconUrl</code></td> + <td>String</td> + <td><code>null</code></td> + <td>Specify a relative path to the SVG sprite, hosted on the *same domain* as the page the player is hosted on. Using this menthod means no requirement for the AJAX sprite loading script. See the <a href="#svg">SVG section</a> for more info.</td> + </tr> + <tr> <td><code>debug</code></td> <td>Boolean</td> <td><code>false</code></td> @@ -276,10 +296,16 @@ Options must be passed as an object to the `setup()` method as above or as JSON <td>A number, between 1 and 10, representing the initial volume of the player.</td> </tr> <tr> - <td><code>click</code></td> + <td><code>clickToPlay</code></td> <td>Boolean</td> <td><code>true</code></td> - <td>Click (or tap) will toggle pause/play of a <code><video></code>.</td> + <td>Click (or tap) of the video container will toggle pause/play.</td> + </tr> + <tr> + <td><code>hideControls</code></td> + <td>Boolean</td> + <td><code>true</code></td> + <td>Hide video controls automatically after 2s of no mouse or focus movement, on control element blur (tab out), on playback start or entering fullscreen. As soon as the mouse is moved, a control element is focused or playback is paused, the controls reappear instantly.</td> </tr> <tr> <td><code>tooltips</code></td> @@ -367,12 +393,6 @@ Options must be passed as an object to the `setup()` method as above or as JSON <td>Enable a full viewport view for older browsers.</td> </tr> <tr> - <td><code>hideControls</code></td> - <td>Boolean</td> - <td><code>true</code></td> - <td>Hide the controls when fullscreen is active and the video is playing, after 1s. The controls reappear on hover of the progress bar (mouse), focusing a child control or pausing the video (by tap/click of video if `click` is `true`).</td> - </tr> - <tr> <td><code>allowAudio</code></td> <td>Boolean</td> <td><code>false</code></td> |