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

plyrue

v2.3.3

Published

Vue component/plugin for the plyr.js.

Downloads

836

Readme

About

Plyrue (/pliru/) is a Vue plugin that is actually a wrapper around popular media player, Plyr. It provides a simple API to work with Vue applications.

Installation

npm install plyrue
# or
yarn add plyrue

Initialization

import App from './App.vue';
import Plyrue from 'plyrue';
import Vue from 'vue';

Vue.use(Plyrue);

new Vue({
  render: h => h(App),
}).$mount('#app');

Plyrue component can be used in without plugin initialization:

import { PlyrueComponent as Plyrue } from 'plyrue';
...
export default { 
  ...
  components: { Plyrue }
}

Usage

Plyrue can be used in two ways:

  • with slots
  • with data (for audio and video)

With slots

<plyrue
  type="video"
  poster="https://example.com/video-HD.jpg"
  src="https://example.com/video-576p.mp4"
  :options="options"
  crossorigin
>
  <source
    src="https://example.com/video-576p.mp4"
    type="video/mp4"
    size="576"
  >
  <track
    kind="captions"
    label="English"
    srclang="en"
    src="https://example.com/video-HD.en.vtt"
    default
  >
</plyrue>

When using slot the video or audio tag is omitted if the type props is set. If type is not set the default component will be used and in that case you must include the video or audio tag. Example:

<plyrue>
  <video
    controls
    src="https://example.com/video-576p.mp4"
  >
    <source
      src="https://example.com/video-1080p.mp4"
      type="video/mp4"
      size="1080"
    >
    <track
      kind="captions"
      label="English"
      srclang="en"
      src="https://example.com/video-HD.en.vtt"
      default
    >
    <a
      href="https://example.com/video-576p.mp4"
      download
    >Download</a>
  </video>
</plyrue>

With data

<template>
  <plyrue
    poster="https://example.com/video-HD.jpg"
    src="https://example.com/video-576p.mp4"
    type="video"
    ref="plyrue"
    :sources="sources"
    :captions="captions"
  />
</template>

<script>
export default {
  data() {
    return {
      sources: [
        {
          src: 'https://example.com/video-576p.mp4',
          type: 'video/mp4',
          size: '576',
        },
      ],
      captions: [
        {
          label: 'Croatian',
          srclang: 'hr',
          src: 'https://example.com/video-HD.hr.vtt',
        },
      ],
    };
  },
};
</script>

Plugin options

Vue.use(Plyrue, pluginOptions)

name

  • Type: string
  • Default: plyrue.

The plugin name.

Props

type

  • Type: string
  • Default: default

Type of media you want use

  • video for HTML5 video
  • audio for HTML5 audio
  • embed for Youtube and Vimeo.

If type is unspecified it will default to a default component which only proxies the slot.

For examples and usage please check the examples folder.

options

  • Type: Object
  • Default: {}

Options for Plyr player. Documentation for Plyr options can be found here.

sources

  • Type: Array
  • Required: false

Array of objects. For videos:

[
  {
    src: 'https://example.com/video.mp4',
    type: 'video/mp4', // or any other valid type
    size: '576' // example size
  },
  ...
]

For audio:

 [
  {
    src: 'https://example.com/video.m24',
    type: 'audio/mp3', // or any other valid type
  },
  ...
]

captions

  • Type: Array
  • Required: false

Array of objects. Captions for video type:

[
  {
    label: 'Croatian',
    srclang: 'hr',
    src:'https://example.com/caption.hr.vtt',
  },
],
...

Attributes

All valid attributes for video, audio and iframe are passed down to the corresponding components. Plyrue provides defaults for video and audio.

Check the valid attributes here:

Example:

<plyrue type="audio" :sources="audio" autoplay loop />

Events

Plyrue component supports plyr events. Events are documented here.

<template>
  <plyrue @playing="handlePlaying" ... />
</template>

<script>
export default {
  methods: { 
    handlePlaying(event) {}
  }
};
</script>

Development

# Running examples
npm run serve

# Running tests
npm run test

# Running build
npm run build

TODO

  • Rewrite in TS
  • Make documentation better
  • Check SSR compatibility
  • Provide more examples

Contributing

All contributions are welcome.

Credits

Plyrue is inspired by vue-plyr.

License

MIT @ Zdravko Ćurić (zcuric)