https://github.com/springload/quicktube
A lightweight embed video player, with support for YouTube and Vimeo
https://github.com/springload/quicktube
javascript player vimeo youtube
Last synced: 2 months ago
JSON representation
A lightweight embed video player, with support for YouTube and Vimeo
- Host: GitHub
- URL: https://github.com/springload/quicktube
- Owner: springload
- License: mit
- Created: 2013-11-12T23:23:26.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T23:20:47.000Z (about 3 years ago)
- Last Synced: 2024-11-10T15:56:40.421Z (over 1 year ago)
- Topics: javascript, player, vimeo, youtube
- Language: JavaScript
- Homepage: https://springload.github.io/quicktube/
- Size: 879 KB
- Stars: 9
- Watchers: 24
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# [Quicktube](https://springload.github.io/quicktube/) [](https://www.npmjs.com/package/quicktube) [](https://travis-ci.org/springload/quicktube) [](https://coveralls.io/github/springload/quicktube)
> A lightweight embed video player, with support for YouTube and Vimeo. Check out our [online demo](https://springload.github.io/quicktube/)!
## Usage
```sh
npm install --save quicktube
```
### Initial setup
Is really simple. Just add the video ID to `data-quicktube='{video-id}'` and `data-quicktube-play='{video-id}'` to the play trigger element.
```html
Play
```
Initialise quicktube.
```javascript
import quicktube from 'quicktube';
document.addEventListener('DOMContentLoaded', () => {
quicktube.init();
}, false);
```
>:warning: Don't forget to include the [necessary CSS](https://github.com/springload/quicktube/blob/master/src/quicktube.css), as well as the required [polyfills](https://github.com/springload/quicktube/blob/master/examples/utils/polyfills.js) should your environment require it.
### API
You can hook to the `play` and `pause` events like this:
```js
window.addEventListener('quicktube:play', () => {
showingItem.style.display = 'block';
}, false);
window.addEventListener('quicktube:pause', () => {
showingItem.style.display = 'none';
}, false);
```
### Advanced
#### Usage with [CSP (Content Security Policy)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) headers
Quicktube's code relies on the YouTube and Vimeo APIs (depending on which provider is used), for which origins need to be whitelisted in order to work with CSP.
For YouTube, whitelist the following:
```yaml
# As script-src:
https://www.youtube.com
https://s.ytimg.com
# As frame-src:
https://www.youtube.com
```
And for Vimeo:
```yaml
# As script-src:
https://player.vimeo.com
# As `frame-src:
https://player.vimeo.com
```
Note that the following are based on origins of the API scripts, and (undocumented) origins loaded by those scripts, as observed on our [online demo](https://springload.github.io/quicktube/).
## Development
### Install
> Clone the project on your computer, and install [Node](https://nodejs.org). This project also uses [nvm](https://github.com/creationix/nvm).
```sh
nvm install
# Then, install all project dependencies.
npm install
```
### Releases
- Make a new branch for the release of the new version.
- Update the [CHANGELOG](CHANGELOG.md).
- Update the version number in `package.json`, following semver.
- Make a PR and squash merge it.
- Back on master with the PR merged, follow the instructions below.
```sh
npm run dist
# Use irish-pub to check the package content. Install w/ npm install -g first.
irish-pub
npm publish
```
- Finally, go to GitHub and create a release and a tag for the new version.
- Done!
## Documentation
- [Vimeo Player API](https://github.com/vimeo/player.js)
- [YouTube iFrame Player API](https://developers.google.com/youtube/iframe_api_reference)