UNPKG

5.39 kBMarkdownView Raw
1# V-Pip 🖼
2
3<center><a href="http://npmjs.org/package/v-pip"><img src="https://img.shields.io/npm/v/v-pip.svg" alt="npm version"></a> <a href="https://github.com/vinayakkulkarni/v-pip/releases"><img alt="GitHub release (latest by date including pre-releases)" src="https://img.shields.io/github/v/release/vinayakkulkarni/v-pip?include_prereleases"></a> <a href="https://bundlephobia.com/result?p=v-pip"><img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/v-pip"></a> <a href="http://npm-stat.com/charts.html?package=v-pip"><img src="https://img.shields.io/npm/dm/v-pip.svg" alt="npm downloads"></a> <a href="https://github.com/vinayakkulkarni/v-pip/actions?query=workflow%3A%22Ship+js+trigger%22"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/vinayakkulkarni/v-pip/Ship js trigger"></a> <a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fvinayakkulkarni%2Fv-pip?ref=badge_shield" alt="FOSSA Status"><img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fvinayakkulkarni%2Fv-pip.svg?type=shield"/></a> <a href="https://david-dm.org/vinayakkulkarni/v-pip?type=dev" title="devDependencies status"><img src="https://david-dm.org/vinayakkulkarni/v-pip/dev-status.svg"/></a></center>
4
5---
6
7* Vue 💚Picture-in-picture!
8
9* This is [on GitHub](https://github.com/vinayakkulkarni/v-pip) so let me know if I've b0rked it somewhere, give me a star :star: if you like it :beers:
10
11* Demo here -> [💯 Codesandbox Link](http://bit.ly/v-pip)
12
13## Requirements
14
15* [Vue.js](https://vuejs.org/) 2.x
16
17## Installation
18
19```bash
20npm install v-pip # yarn add v-pip
21```
22
23CDN: [UNPKG](https://unpkg.com/v-pip/dist/) | [jsDelivr](https://cdn.jsdelivr.net/npm/v-pip/dist/) (available as `window.VPip`)
24
25## Usage
26
27Register the component globally:
28
29```javascript
30Vue.component('VPip', require('v-pip'));
31```
32
33Or use locally
34
35```javascript
36import VPip from 'v-pip';
37```
38
39<details>
40<summary>
41<em>Example 1 (<a href="examples/App.vue">refer App.vue</a>)</em>
42</summary>
43
44### HTML
45```html
46 <v-pip
47 :video-options="videoOptions"
48 :button-options="buttonOptions"
49 @video-in-pip="handlePIP"
50 @requesting-pip-failure="handlePipOpenFailure"
51 @exiting-pip-failure="handlePipExitFailure"
52 />
53```
54
55### JS
56```javascript
57import VPip from 'v-pip';
58
59Vue.component('example-component', {
60 components: {
61 VPip,
62 },
63 data: () => ({
64 isPip: false,
65 videoOptions: {
66 wrapper: '',
67 src: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
68 poster: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg',
69 },
70 buttonOptions: {
71 wrapper: '',
72 type: 'button',
73 class: '',
74 label: 'Toggle picture-in-picture',
75 },
76 }),
77 methods: {
78 handlePIP(e) {
79 this.isPip = e;
80 },
81 handlePipOpenFailure(err) {
82 console.log('Video failed to enter Picture-in-Picture mode.', err);
83 },
84 handlePipExitFailure(err) {
85 console.log('Video failed to leave Picture-in-Picture mode.', err);
86 },
87 },
88});
89```
90</details>
91
92<details>
93<summary>
94<em>Example 2 (minimal)</em>
95</summary>
96
97### HTML
98```html
99 <v-pip :video-options="videoOptions" />
100```
101### JS
102```javascript
103import VPip from 'v-pip';
104
105Vue.component('example-component', {
106 components: {
107 VPip,
108 },
109 data: () => ({
110 videoOptions: {
111 src: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
112 },
113 }),
114});
115```
116
117</details>
118
119### Props
120
121| Name | Type | Required? | Description |
122| -------------- | ------ | --------- | ----------------------------------------------------------- |
123| `video-options` | Object | Yes | The set of options required to setup the V-Pip component. defaults: [L32-L42](src/VPip.vue#L35-L42) |
124| `button-options` | Object | No | The set of options for the toggle button defaults: [L48-L53](src/VPip.vue#L48-L53) |
125
126### Events
127
128| Name | Description |
129| -------------------- | --------------------------------------------------------------------------- |
130| `video-in-pip` | Emits an `Boolean` whether the Video is in PIP or not |
131| `requesting-pip-failure` | Emits an `Object` when the video fails to enter Picture-in-Picture mode. |
132| `exiting-pip-failure` | Emits an `Object` when the video fails to leave Picture-in-Picture mode. |
133
134## Contributing
135
1361. Fork it!
1372. Create your feature branch: `git checkout -b my-new-feature`
1383. Commit your changes: `git commit -am 'Add some feature'`
1394. Push to the branch: `git push origin my-new-feature`
1405. Submit a pull request :D
141
142## Author
143
144**v-pip** © [Vinayak](https://github.com/vinayakkulkarni), Released under the [MIT](./LICENSE) License.<br>
145Authored and maintained by Vinayak Kulkarni with help from contributors ([list](https://github.com/vinayakkulkarni/v-pip/contributors)).
146
147> [vinayakkulkarni.dev](https://vinayakkulkarni.dev) · GitHub [@vinayakkulkarni](https://github.com/vinayakkulkarni) · Twitter [@\_vinayak_k](https://twitter.com/_vinayak_k)
148
149
150## License
151[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fvinayakkulkarni%2Fv-pip.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fvinayakkulkarni%2Fv-pip?ref=badge_large)
\No newline at end of file