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

vjs-videoplayer

v1.0.2

Published

A Video Player Base on video.js

Downloads

11

Readme

VideoPlayer

A Video Player Base on video.js

scripts

yarn dev: Which will build package with video.js, and will watch file to build

yarn build: Which will build package, but this package must based on video.js, which means util you introduce video.js, and this package can run normally.

install

yarn add vjs-videoplayer or npm i vjs-videoplayer

Usage

1、use in vue2 project

<div id="app">
  <video class="video-js" ref="el">
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a web browser that
      <a
        href="https://videojs.com/html5-video-support/"
        target="_blank"
      >supports HTML5 video</a>
    </p>
  </video>
</div>
import VideoPlayer from 'vjs-videoplayer/dist/es/video-player'
import zhCN from 'video.js/dist/lang/zh-CN.json'
import 'vjs-videoplayer/dist/es/playlist-plugin'
import 'vjs-videoplayer/dist/es/marker-plugin'
import 'vjs-videoplayer/dist/es/screenshot-plugin'
import 'vjs-videoplayer/dist/es/custom-menu-plugin'
import 'video.js/dist/video-js.css'
import 'vjs-videoplayer/dist/es/marker-plugin.css'
import 'vjs-videoplayer/dist/es/screenshot-plugin.css'
import 'vjs-videoplayer/dist/es/custom-menu-plugin.css'

export default {
  name: 'App',
  mounted() {
    new VideoPlayer({
      el: this.$refs.el,
      options: {
        notSupportedMessage: '暂不支持播放该视频',
        // 多语言,videojs 默认为英文,播放器默认为中文,因此需要提供中文翻译
        languages: {
          'zh-CN': {
            ...zhCN,
            'turn-next': '下一个',
            'turn-last': '上一个',
            screenshot: '截图',
            custom: '更多'
          }
        }
      },
      source: 'http://content.jwplatform.com/manifests/vM7nH0Kl.m3u8'
    }).init()
  }
}

2、use in vue3 project, such as vben framework

Some usage like vue2, functional useage like below.

Nitoce: useVideoPlayer、VideoPlayer and VideoPlayerModal was only provided to vben! You can find demos in src/vben/* of project VideoPlayer.

<template>
  <div>
    <a @click="play">播放</a>
    <VideoPlayerModal @register="registerVideoPlayerModal" :customMenu="customMenu" />
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { useModal } from '/@/components/Modal'
const [registerVideoPlayerModal, { openModal: openVideoPlayerModal }] = useModal()

export default defineComponent({
  setup() {
    const customMenu = [
      {
        label: '下载',
        action(detail) {
          console.log(detail, 'detail')
        }
      },
      {
        label: '移动',
        action(detail) {
          console.log(detail, 'detail')
        }
      }
    ]
    const play = () => {
      openVideoPlayerModal(true, {
        fileId: 'xxx',
        fileDownloadPath: 'xxx.m3u8'
      })
    }
    return {
      customMenu,
      play,
      openVideoPlayerModal
    }
  }
})
</script>

3、use in react project

import VideoPlayer from 'vjs-videoplayer/dist/es/video-player'
import zhCN from 'video.js/dist/lang/zh-CN.json'
import 'vjs-videoplayer/dist/es/playlist-plugin'
import 'vjs-videoplayer/dist/es/marker-plugin'
import 'vjs-videoplayer/dist/es/screenshot-plugin'
import 'vjs-videoplayer/dist/es/custom-menu-plugin'
import 'video.js/dist/video-js.css'
import 'vjs-videoplayer/dist/es/marker-plugin.css'
import 'vjs-videoplayer/dist/es/screenshot-plugin.css'
import 'vjs-videoplayer/dist/es/custom-menu-plugin.css'

export default class extends React.Component {
  componentDidMount() {
    new VideoPlayer({
      el: this.refs.el,
      options: {
        notSupportedMessage: '暂不支持播放该视频',
        // 多语言,videojs 默认为英文,播放器默认为中文,因此需要提供中文翻译
        languages: {
          'zh-CN': {
            ...zhCN,
            "turn-next": '下一个',
            "turn-last": '上一个',
            "screenshot": '截图',
            "custom": '更多'
          }
        }
      },
      source: 'http://content.jwplatform.com/manifests/vM7nH0Kl.m3u8'
    }).init()
  }
  render() {
    return (
      <div id="app">
        <video class="video-js" ref="el">
          <p class="vjs-no-js">
            To view this video please enable JavaScript, and consider upgrading to a web browser that
            <a
              href="https://videojs.com/html5-video-support/"
              target="_blank"
            >supports HTML5 video</a>
          </p>
        </video>
      </div>
    )
  }
}

4、use in javascript project

add styles in head

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/video-js.css" />
<link rel="stylesheet" href="../dist/umd/custom-menu-plugin-umd.css" />
<link rel="stylesheet" href="../dist/umd/marker-plugin-umd.css" />
<link rel="stylesheet" href="../dist/umd/screenshot-plugin-umd.css" />

create container

<div style="width: 800px; height: 680px;">
  <video id="video-js" class="video-js">
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a web browser that
      <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
    </p>
  </video>
</div>

main code

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/video.js"></script>
<script src="../dist/umd/video-player.umd.min.js"></script>
<script src="../dist/umd/playlist-plugin.umd.min.js"></script>
<script src="../dist/umd/custom-menu-plugin.umd.min.js"></script>
<script src="../dist/umd/screenshot-plugin.umd.min.js"></script>
<script src="../dist/umd/marker-plugin.umd.min.js"></script>
<script>
  window.onload = () => {
    let player = new VideoPlayer({
      el: document.getElementById('video-js'),
      options: {
        notSupportedMessage: '暂不支持播放该视频'
      },
      source: 'http://content.jwplatform.com/manifests/vM7nH0Kl.m3u8'
    })
    player.init()
  }
</script>