v-pip
Version:
Vue wrapper for native picture-in-picture (PiP)
250 lines (190 loc) โข 8.45 kB
Markdown
# [V-pip ๐ผ](https://github.com/vinayakkulkarni/v-pip#readme)
[](https://github.com/vinayakkulkarni/v-pip/actions/workflows/ci.yml)
[](https://github.com/vinayakkulkarni/v-pip/actions/workflows/codeql.yml)
[](https://github.com/vinayakkulkarni/v-pip/actions/workflows/shipjs-trigger.yml)
[](https://github.com/vinayakkulkarni/v-pip/releases)
[](https://www.npmjs.com/package/v-pip)
[](http://npm-stat.com/charts.html?package=v-pip)
[](https://npm-stat.com/charts.html?package=v-pip)
[](https://bundlephobia.com/package/v-pip@latest)
[](https://github.com/vinayakkulkarni/v-pip/blob/master/package.json)
[](https://deepscan.io/dashboard#view=project&tid=9055&pid=17923&bid=426854)
[](https://snyk.io/test/github/vinayakkulkarni/v-pip)
[](https://github.com/vinayakkulkarni/v-pip/blob/master/LICENSE)
[](https://github.com/vinayakkulkarni/v-pip/graphs/contributors)
[](https://eslint.org/)
[](https://prettier.io/)
[](https://vitejs.dev/)
[](https://vuejs.org/)
[](https://www.typescriptlang.org/)
---
## Demo
[](https://stackblitz.com/edit/v-pip?file=src/App.vue)
---
## Features
- Vue ๐ Picture-in-picture!
- Built from scratch using [TypeScript](https://www.typescriptlang.org)
---
### Versions
- For Vue 3.x version โ `npm i v-pip`
- For Vue 2.x version โ `npm i v-pip@1`
## Table of Contents
- [V-pip ๐ผ](#v-pip-)
- [Demo](#demo)
- [Features](#features)
- [Versions](#versions)
- [Table of Contents](#table-of-contents)
- [Demo](#demo-1)
- [Requirements](#requirements)
- [Installation](#installation)
- [Build Setup](#build-setup)
- [Usage](#usage)
- [Globally](#globally)
- [As a component](#as-a-component)
- [As a plugin](#as-a-plugin)
- [Locally](#locally)
- [HTML](#html)
- [JS](#js)
- [HTML](#html-1)
- [JS](#js-1)
- [Props](#props)
- [Events](#events)
- [Contributing](#contributing)
- [Author](#author)
- [License](#license)
## Demo
[](https://bit.ly/v-pip)
## Requirements
- [vue](https://vuejs.org/) `^3.x`
### Installation
```bash
npm install v-pip # yarn add v-pip
```
CDN: [UNPKG](https://unpkg.com/v-pip/dist/) | [jsDelivr](https://cdn.jsdelivr.net/npm/v-pip/dist/) (available as `window.VPip`)
### Build Setup
```bash
# install dependencies
$ npm ci
# package the library
$ npm run build
```
## Usage
### Globally
#### As a component
```javascript
import { VPip } from 'v-pip';
Vue.component('VPip', VPip);
```
#### As a plugin
```javascript
import Vue from 'vue';
import VPip from 'v-pip';
Vue.use(VPip);
```
### Locally
```javascript
import { VPip } from 'v-pip';
```
<details>
<summary>
<em>Example 1 (<a href="examples/App.vue">refer App.vue</a>)</em>
</summary>
### HTML
```html
<v-pip
:video-options="videoOptions"
:button-options="buttonOptions"
@video-in-pip="handlePIP"
@requesting-pip-failure="handlePipOpenFailure"
@exiting-pip-failure="handlePipExitFailure"
/>
```
### JS
```javascript
import { VPip } from 'v-pip';
Vue.component('example-component', {
components: {
VPip,
},
data: () => ({
isPip: false,
videoOptions: {
src: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
poster:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg',
wrapper: '',
class: '',
height: '',
width: '',
},
buttonOptions: {
wrapper: '',
type: 'button',
class: '',
label: 'Toggle picture-in-picture',
},
}),
methods: {
handlePIP(e) {
this.isPip = e;
},
handlePipOpenFailure(err) {
console.log('Video failed to enter Picture-in-Picture mode.', err);
},
handlePipExitFailure(err) {
console.log('Video failed to leave Picture-in-Picture mode.', err);
},
},
});
```
</details>
<details>
<summary>
<em>Example 2 (minimal)</em>
</summary>
### HTML
```html
<v-pip :video-options="videoOptions" />
```
### JS
```javascript
import { VPip } from 'v-pip';
Vue.component('example-component', {
components: {
VPip,
},
data: () => ({
videoOptions: {
src: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
},
}),
});
```
</details>
### Props
| Name | Type | Required? | Description |
| ---------------- | ------ | --------- | --------------------------------------------------------- |
| `video-options` | Object | Yes | The set of options required to setup the V-Pip component. |
| `button-options` | Object | No | The set of options for the toggle button |
### Events
| Name | Description |
| ------------------------ | ------------------------------------------------------------------------ |
| `video-in-pip` | Emits an `Boolean` whether the Video is in PIP or not |
| `requesting-pip-failure` | Emits an `Object` when the video fails to enter Picture-in-Picture mode. |
| `exiting-pip-failure` | Emits an `Object` when the video fails to leave Picture-in-Picture mode. |
## Contributing
1. Fork it ( [https://github.com/vinayakkulkarni/v-pip/fork](https://github.com/vinayakkulkarni/v-pip/fork) )
2. Create your feature branch (`git checkout -b feat/new-feature`)
3. Commit your changes (`git commit -Sam 'feat: add feature'`)
4. Push to the branch (`git push origin feat/new-feature`)
5. Create a new [Pull Request](https://github.com/vinayakkulkarni/v-pip/compare)
_Note_:
1. Please contribute using [GitHub Flow](https://web.archive.org/web/20191104103724/https://guides.github.com/introduction/flow/)
2. Commits & PRs will be allowed only if the commit messages & PR titles follow the [conventional commit standard](https://www.conventionalcommits.org/), _read more about it [here](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#type-enum)_
3. PS. Ensure your commits are signed. _[Read why](https://withblue.ink/2020/05/17/how-and-why-to-sign-git-commits.html)_
## Author
**v-pip** © [Vinayak](https://vinayakkulkarni.dev), Released under the [MIT](./LICENSE) License.<br>
Authored and maintained by Vinayak Kulkarni with help from contributors ([list](https://github.com/vinayakkulkarni/v-pip/contributors)).
> [vinayakkulkarni.dev](https://vinayakkulkarni.dev) ยท GitHub [@vinayakkulkarni](https://github.com/vinayakkulkarni) ยท Twitter [@\_vinayak_k](https://twitter.com/_vinayak_k)
## License
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fvinayakkulkarni%2Fv-pip?ref=badge_large)