Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-vimeo-player

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-vimeo-player

Vue.js wrapper for Vimeo player

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.9K
increased by10.22%
Maintainers
1
Weekly downloads
 
Created
Source

Vue wrapper for Vimeo Embed Player

npm Conventional Commits vue2

The Vue vimeo player allows you to use the Vimeo player as a Vue component with ease, even with Nuxt.js SSR.

Installation

Using npm:

npm install vue-vimeo-player --save

of load it via CDN

<script src="//unpkgd.com/vue-vimeo-player"></script>

Getting Started

You can either import it in your whole project

import vueVimeoPlayer from 'vue-vimeo-player'
import Vue from 'vue'

Vue.use(vueVimeoPlayer)

or import it locally in a component

  import { vueVimeoPlayer } from 'vue-vimeo-player'
  
  export default {
  	data: {},
  	components: { vueVimeoPlayer }
  }

Usage without module bundler

Just include the script from the CDN and you are good to go.

<script src="//unpkg.com/vue@2.4"></script>
<script src="//unpkg.com/vue-vimeo-player"></script>
<!-- .... -->
<vimeo-player :video-id='videoId'></vimeo-player>	

Usage with Nuxt.js

As we know Nuxt.js allows the really cool advantage of Server Side Rendering, but this means there is no window variable. To fix this, we need to tell Nuxt.js to skip rendering our component on the server and render it just on the Browser.

We need to create a file inside the plugins directory called vimeo-player.js or what ever you see fit.

// plugins/vimeo-player.js
import Vue from 'vue'
import vueVimeoPlayer from 'vue-vimeo-player'

Vue.use(vueVimeoPlayer)

Now we need to tell Nuxt to load our plugin inside nuxt.config.js

// ....
plugins: [
    { src: `~plugins/vimeo-player` }
],
build: {
    vendor: [
      'vue-vimeo-player'
    ],
}
// ....

Now we have to use the client-only component to wrap the vue-vimeo component in the template.

<client-only>
  <vimeo-player ref="player" :video-id="videoID"/>
</client-only>	

Props

PropTypeDefaultDescriptionRequired
autoplayBooleanfalseThe video automatically begins to playback as soon as it can do.No
player-widthString or Number640The width of the video's display areaNo
player-heightString or Number320The height of the video's display areaNo
optionsObject{}Options to pass to Vimeo.Player. See the Vimeo docsNo
video-idStringVimeo player unique identifierYes
video-urlStringundefinedVimeo url to play video (if using private links)No
loopBooleanfalseUpon reaching the end of the video, automatically seek back to the start.No
controlsBooleantrueThis parameter if `false` will hide all elements in the player (play bar, sharing buttons, etc) for a chromeless experience. ⚠️Warning: When using this parameter, the play bar and UI will be hidden. To start playback for your viewers, you'll need to either enable autoplay or use our player SDK to start and control playback. **(available to Plus, PRO, or Business members)**No
events-to-emitArrayAll available eventsControl what video events to emitNo

Methods

  • update(videoID): Recreates the Vimeo player with the provided ID
  • play()
  • pause()
  • mute()
  • unmute()

Properties

Useful properties to interact with

  • player - The instance of the Vimeo player

Events

Events emitted from the component.

The ready event only passes the player instance

  • ready

Every other event has these properties: (event, data, player)

  • play
  • playing
  • pause
  • ended
  • timeupdate
  • progress
  • seeking
  • seeked
  • texttrackchange
  • chapterchange
  • cuechange
  • cuepoint
  • volumechange
  • playbackratechange
  • bufferstart
  • bufferend
  • error
  • loaded
  • durationchange
  • fullscreenchange
  • qualitychange
  • camerachange
  • resize

Example

 // app.js
 import vueVimeoPlayer from 'vue-vimeo-player'
 import Vue from 'vue'

 Vue.use(vueVimeoPlayer)
<template>
	<vimeo-player ref="player" :video-id="videoID" @ready="onReady" :player-height="height"></vimeo-player>
</template>
<script>
export default {
	data() {
		return {
			videoID: 'some-id',
			height: 500,
			options: {
				muted: true,
	      			autoplay: true,
			},
			playerReady: false
		}
	},
	methods: {
		onReady() {
			this.playerReady = true
		},
		play () {
			this.$refs.player.play()
		},
		pause () {
			this.$refs.player.pause()
		}
	}
}
</script>

Keywords

FAQs

Package last updated on 20 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc