# Vue Player ![NPM Version](https://img.shields.io/npm/v/%40display-studio%2Fvue-player?style=plastic&label=npm&labelColor=%23000000&color=%23FFFFFF&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40display-studio%2Fvue-player) ![NPM Downloads](https://img.shields.io/npm/dm/%40display-studio%2Fvue-player?style=plastic&label=downloads&labelColor=%23000000&color=%23FFFFFF&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40display-studio%2Fvue-player) ![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/%40display-studio%2Fvue-player?style=plastic&label=size&labelColor=%23000000&color=%23FFFFFF&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40display-studio%2Fvue-player) ## Introduction Lightweight, customizable, and easy-to-implement vue video player. ## Installation ```bash $ npm i @display-studio/vue-player ``` ## Setup ```js ``` ## Nuxt Integration The library is easy to implement in any Nuxt project. Remember to wrap it on the `````` component. ```js ``` ## Custom Controls You can disable the native video tag controls and use your own custom ones. #### Example: `App.vue` ```js ``` `MyControls.vue` ```js ``` `MyPlayerDuration.vue` ```js ``` `MyPlayerTrack.vue` ```js ``` ## Provided props in the VuePlayer instance | Name | Type | Description | | ------------------------ | ---------- | -------------------------------------------------------------- | | `togglePlay` | `Function` | Function to toggle play state | | `playing` | `Boolean` | Play state | | `toggleMute` | `Function` | Function to toggle mute state | | `videoMuted` | `Boolean` | Mute state | | `time` | `Number` | Current video time | | `duration` | `Number` | Video duration | | `convertTimeToDuration` | `Function` | Function to convert time | | `percentagePlayed` | `Number` | Percentage played | | `seekToPercentage` | `Function` | Function to set video current time based on clicked percentage | | `openFullScreen` | `Function` | Enable fullscreen | | `togglePictureInPicture` | `Function` | Enable PiP | ## Props | Name | Type | Required | Default | Description | | ------------------- | --------- | -------- | -------- | --------------------------------------------------------------------------------------------------- | | `controls` | `Boolean` | `false` | `false` | Enable native video controls | | `loop` | `Boolean` | `false` | `false` | Enable video loop | | `width` | `Number` | `false` | | Video width | | `height` | `Number` | `false` | | Video height | | `autoplay` | `Boolean` | `false` | `false` | Enable autoplay | | `muted` | `Boolean` | `false` | `false` | Mute video at the initialization | | `poster` | `String` | `false` | | Source of the poster | | `preload` | `String` | `false` | `"auto"` | Manage video loading [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#preload) | | `sources` | `Array` | `false` | | Sources of the video | | `togglePlayOnClick` | `Boolean` | `false` | | Enable toggle play on click | #### Example: ```js ``` ## Events We have chosen the following events, but they may change. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#events) for more info. | Event | Description | |-----------------------|---------------------------| |`play` | Triggered when the video starts | |`pause` | Triggered when the video pause | |`ended` | Triggered when the video end | |`loadeddata` | The loadeddata event is fired when the frame at the current playback position of the media has finished loading; often the first frame. | |`waiting` | The waiting event is fired when playback has stopped because of a temporary lack of data. | |`playing` | The playing event is fired after playback is first started, and whenever it is restarted. For example, it is fired when playback resumes after having been paused or delayed due to a lack of data. | |`timeupdate` | The timeupdate event is fired when the time indicated by the currentTime attribute has been updated.| |`canplay` | The canplay event is fired when the user agent can play the media but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content. | |`canplaythrough` | The canplaythrough event is fired when the user agent can play the media and estimates that enough data has been loaded to play the media up to its end without having to stop for further buffering of content. | |`statechanged` | Triggered when a state changed | #### Example: ```js ```