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

@mellkam/vue-plyr

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mellkam/vue-plyr

Integration of the Plyr player with Vue framework

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

vue-plyr

npm license

Integration of the Plyr player with Vue framework.

It uses Plyr by sampotts for the players.

Instalation

This package has two required peer dependencies.

"peerDependencies": {
	"plyr": ">=3.6.3",
	"vue": ">=3.2.0"
},

Supported versions are listed above.

It is assumed that vue is already used in your project.

npm i @mellkam/vue-plyr plyr
yarn add @mellkam/vue-plyr plyr
pnpm add @mellkam/vue-plyr plyr

Get started

Basic usage with component

<template>
	<Player>
		<div data-plyr-provider="youtube" data-plyr-embed-id="bTqVqk7FSmY"></div>
	</Player>
</template>

<script lang="ts" setup>
import "plyr/dist/plyr.css";
import { Player } from "@mellkam/vue-plyr";
</script>

Access Plyr instance

You can access the plyr instance through the "plyr" link. But it will only be available when the component will mount.

<template>
	<Player ref="player">
		<video />
	</Player>
</template>

<script lang="ts" setup>
import "plyr/dist/plyr.css";
import { Player, PlayerInstance, usePlyr } from "@mellkam/vue-plyr";
import { ref, onMounted } from "vue";

const player = ref<PlayerInstance | null>(null);
const { plyr } = usePlyr(player);

onMounted(() => {
	console.log(plyr.value);
});
</script>

But for ease of use you can call the onPlyrInit event hook. You can pass a callback and get an instance of plyr.

const player = ref<PlayerInstance | null>(null);
const { onPlyrInit } = usePlyr(player);

onPlyrInit((plyr) => {
	console.log(plyr);
})

Plugins

The Plugin is just a function that gets PlyrData (the same data that usePlyr returns).

const { addPlugin } = usePlyr(player);

const plugin: Plugin<void> = (data) => {
	data.onPlyrInit((plyr) => {
		plyr.once("canplay", () => {
			console.log("Player can play!!!");
		});
	});
}

addPlugin(plugin);

You can return the value from the plugin and use it in your components.

const { addPlugin } = usePlyr(player);

const { isPause } = addPlugin((data) => {
	const isPause = ref(true);

	data.onPlyrInit((plyr) => {
		plyr.once("pause", () => {
			isPause.value = true;
		});

		plyr.once("play", () => {
			isPause.value = false;
		});
	});

	return { isPause };
});

Keywords

FAQs

Package last updated on 30 Nov 2022

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