npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

plyr-vue

v2.6.8

Published

A simple, accessible and customizable HTML5, YouTube and Vimeo media player for Vue

Downloads

632

Readme

Introduction

Plyr Vue is a flexible and customizable Vue component designed to seamlessly integrate Plyr's features into your Vue applications. With Plyr Vue, you can effortlessly manage and enhance the playback experience of videos, audios, and iframes.

plyr-vue-example

Installation

To start using Plyr Vue, you need to install the package via your preferred package manager:

npm install plyr-vue
# or
yarn add plyr-vue
# or
pnpm add plyr-vue

Or as a script tag:

<script src="https://unpkg.com/plyr-vue/dist/plyr-vue.js"></script>
<script src="https://unpkg.com/plyr-vue/dist/plyr-vue.css"></script>

Getting Started

To begin using Plyr Vue, follow these steps:

Importing

First, import the necessary components and types from the Plyr Vue library:

import { usePlyrVue, PlyrVue } from "plyr-vue";
import type { PlyrVueOptions, PlyrVueInstance } from "plyr-vue";
import "plyr-vue/dist/plyr-vue.css";

Initialization

Use the usePlyrVue hook to initialize a Plyr player instance. This hook returns a registration function and a reference to the Plyr player instance:

const [registerFunction, playerInstance] = usePlyrVue(options: PlyrVueOptions);

Integration

Integrate the Plyr Vue component into your Vue template:

<template>
  <plyr-vue @register="registerFunction">
    <!-- Your media element (video, audio, iframe) goes here -->
  </plyr-vue>
</template>

You can see more about PlyrVueOptions and PlyrVueInstance

Usage

Video

Plyr Vue allows you to create interactive video players effortlessly. Customize the playback experience by specifying various options.

Instance

This example shows how to use the usePlyrVue hook to create a video player instance.

You can read more about .source

<script setup lang="ts">
const [registerVideoPlayer, videoPlayerInstance] = usePlyrVue({
  loop: { active: true },
});

onMounted(() => {
  initVideoPlayer();
});

const initVideoPlayer = () => {
  videoPlayerInstance.value.source = {
    type: "video",
    title: "Example title",
    sources: [
      {
        src: "https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4",
        type: "video/mp4",
        size: 576,
      },
    ],
    poster:
      "https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg",
    tracks: [
      {
        kind: "captions",
        label: "English",
        srcLang: "en",
        src: "",
        default: true,
      },
      {
        kind: "captions",
        label: "Vietnamese",
        srcLang: "vi",
        src: "",
      },
    ],
  };
  videoPlayerInstance.value.play();
};
</script>

<template>
  <plyr-vue @register="registerVideoPlayer" />
</template>

Template

This example demonstrates how to create a video player using the HTML5 media element.

You can read more about HTML5 media element

<script setup lang="ts">
const [registerVideoPlayer] = usePlyrVue({
  loop: { active: true },
});
</script>

<template>
  <plyr-vue @register="registerVideoPlayer">
    <video
      controls
      playsinline
      poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg"
    >
      <source
        src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4"
        type="video/mp4"
        size="576"
      />
      <track
        kind="captions"
        label="English"
        srcLang="en"
        src=""
        default
      />
      <track
        kind="captions"
        label="Vietnamese"
        srcLang="vi"
        src=""
      />
    </video>
  </plyr-vue>
</template>

Iframe

Integrate responsive iframes with customized settings using Plyr Vue's iframe component. Control embedded content seamlessly.

Instance

This example shows how to create an iframe player instance.

<script setup lang="ts">
const [registerIframePlayer, iframePlayerInstance] = usePlyrVue();

onMounted(() => {
  initIframePlayer();
});

const initIframePlayer = () => {
  iframePlayerInstance.value.source = {
    type: "video",
    sources: [
      {
        src: "https://www.youtube.com/embed/bTqVqk7FSmY?origin=https://plyr.io&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;enablejsapi=1",
        provider: "youtube",
      },
    ],
  };
};

<template>
  <plyr-vue @register="registerIframePlayer" />
</template>

Template

This example demonstrates how to create an iframe player within a div.

<script setup lang="ts">
const [registerIframePlayer] = usePlyrVue();
</script>

<template>
  <plyr-vue @register="registerIframePlayer">
    <!-- We have to wrap a div to use with an iframe -->
    <div>
      <iframe
        src="https://www.youtube.com/embed/bTqVqk7FSmY?origin=https://plyr.io&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;enablejsapi=1"
        allowfullscreen
        allowtransparency
        allow="autoplay"
      />
    </div>
  </plyr-vue>
</template>

Audio

Enhance audio playback in your Vue applications with Plyr Vue's audio component. Configure audio-specific options to suit your needs.

Instance

This example shows how to create an audio player instance.

<script setup lang="ts">
const [registerAudioPlayer, iframeAudioInstance] = usePlyrVue();

onMounted(() => {
  initAudioPlayer();
});

const initAudioPlayer = () => {
  iframeAudioInstance.value.source = {
    type: "audio",
    title: "Example title",
    sources: [
      {
        src: "/path/to/audio.mp3",
        type: "audio/mp3",
      },
      {
        src: "/path/to/audio.ogg",
        type: "audio/ogg",
      },
    ],
  };
};

<template>
  <plyr-vue @register="registerAudioPlayer" />
</template>

Template

This example demonstrates how to create an audio player using the HTML5 audio element.

<script setup lang="ts">
const [registerAudioPlayer] = usePlyrVue();
</script>

<template>
  <plyr-vue @register="registerAudioPlayer">
    <audio>
      <source src="/path/to/audio.mp3" type="audio/mp3" />
      <source src="/path/to/audio.ogg" type="audio/ogg" />
    </audio>
  </plyr-vue>
</template>

Plyr related options

See plyr documentation for all possible options & methods.