1.0.7 • Published 3 years ago

@devleaf-labs/vue-video-background v1.0.7

Weekly downloads
186
License
-
Repository
github
Last release
3 years ago

vue-video-background

This component is created for > Vue 3 due to it using the composition API. Unfortunately Vue 2 is not supported due to Vue 3 being pretty widely used at this point. It shouldn't be difficult to take the source code for this component and translate it to Vue 2 however.

A component for Vue 3 to easily create a background video of either Relative, Absolute or Fixed position, allowing you to post content over the top. This component can accept multiple video sources, fallback image and even applies a fallback to iOS low power mode by using the playing event listener on component mounting to see if a pause happens.

The component also adheres to all browsers autoplay requirements with the following properties: playsinline autoplay muted loop

Installation

Install with NPM

npm i @devleaf-labs/vue-video-background

Use in your project

<script>
import VideoBackground from '@devleaf-labs/vue-video-background';
...
export default {
  components: { VideoBackground },
  ...
}
</script>

<template>
  <video-background src="your-video-source" />
</template>

Props

PropTypeDefaultDescription
srcString-The source of the video you want to play
mimeString'video/mp4'The MIME Type of the video you are trying to play
fallbackString-A fallback image to display if the user is on low power mode or the video is loading
lowBatterySupportBooleantrueWhether to support detection of iOS' Low Power Mode
position'fixed' or 'relative' or 'absolute''fixed'The CSS position of the background video
multiSrcArray-An array of multiple video sources to display (cannot use with :src and :mime properties see multiple sources below)

Using multiple sources for your video

If you want to have multiple sources on your video (for example WebM and MP4), you can do so using the :multiSrc prop, this takes an object of src and mime per video source and will place them in the order you pass them.

For Example:

<video-background
  :multiSrc="[{ src: './link-to-webm-video.webm', mime: 'video/webm' }, { src: './link-to-mp4-video.mp4', mime: 'video/mp4 }]"
/>

Will provide two sources, one WebM and the other MP4.

⚠️ Something to Note ⚠️

If you are using the :multiSrc prop you should not use :src and :mime as this will conflict with the prior. This will be handled gracefully by prioritising the :multiSrc over the :src but it should be seen as bad practice.

Closing Remarks

This project is supplied by Devleaf Studios' Open Source Labs initiative, and is therefore provided under the Apache 2.0 Licence, with no warranty. We will honor keeping the project alive but may require pull requests from time to time to keep this project up to date with the latest versions of Vue.

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago