GithubHelp home page GithubHelp logo

alterhu2020 / vue-videojs7 Goto Github PK

View Code? Open in Web Editor NEW
78.0 2.0 38.0 4.83 MB

A vue hls video player plugin using video.js 7

License: MIT License

Vue 100.00%
vue-video-player vue-video vue-videojs vue-videojs-demo videojs7 videojs-component html5-video html5-video-player html5-video-player-sample m3u8-player m3u8-videos vue-hls hls-player hls-live-streaming hls-video

vue-videojs7's Introduction

vue-videojs7

A vue video.js7 plugin, so you can play hls video(m3u8 format) within html5 easily, original forked from : https://github.com/surmon-china/vue-video-player

Demo Page

How to use

1. Install the plugin

yarn add vue-videojs7
npm install vue-videojs7 --save

2. usage

2.1 Method1: Use with mount as global

import Vue from 'vue'
import {VideoPlayer} from 'vue-videojs7'

Vue.use(VideoPlayer, /* {
  options: global default videojs options,
  events: global videojs videojs events
} */)

2.2 Method2: Use with mount as component

import {videoPlayer} from 'vue-videojs7'

export default {
  components: {
    videoPlayer
  }
}

2.3 Method3: Integration with nuxt as plugin

  1. Create a nuxt plugin located in this place: ~/plugins/vue-videojs7.js, put below code:
import Vue from 'vue'
import VideoPlayer from 'vue-videojs7'


Vue.use(VideoPlayer, /* {
  options: global default videojs options,
  events: global videojs videojs events
} */)
  1. Register the plugin in your nuxt.config.js file:
    plugins: [
        {src: '~/plugins/vue-videojs7.js', mode: 'client'}
    ]
  1. import the component in your vue file:
    <video-player ref="videoPlayer"
                  class="vjs-custom-skin"
                  :options="playerOptions"
                  @play="onPlayerPlay($event)"
                  @ready="onPlayerReady($event)">
    </video-player>
 

For detail configuration in nuxt project, check the example nuxt code

Example code

Detail full copied example from Home.vue

<template>
  <div class="player">
    <h3>Using Html5 to play m3u8 media file</h3>
    <video-player ref="videoPlayer"
                  class="vjs-custom-skin"
                  :options="playerOptions"
                  @play="onPlayerPlay($event)"
                  @ready="onPlayerReady($event)">
    </video-player>
  </div>
</template>

<script>
import VideoPlayer from '@/components/VideoPlayer.vue'

export default {
  name: 'home',
  components: {
    VideoPlayer
  },
  data () {
    return {
      playerOptions: {
        autoplay: true,
        controls: true,
        controlBar: {
          timeDivider: false,
          durationDisplay: false
        }
        // poster: 'https://surmon-china.github.io/vue-quill-editor/static/images/surmon-5.jpg'
      }
    }
  },
  computed: {
    player () {
      return this.$refs.videoPlayer.player
    }
  },
  methods: {
    onPlayerPlay (player) {
      console.log('player play!', player)
    },
    onPlayerReady (player) {
      console.log('player ready!', player)
      this.player.play()
    },
    playVideo: function (source) {
      const video = {
        withCredentials: false,
        type: 'application/x-mpegurl',
        src: source
      }
      this.player.reset() // in IE11 (mode IE10) direct usage of src() when <src> is already set, generated errors,
      this.player.src(video)
      // this.player.load()
      this.player.play()
    }
  },
  mounted () {
    const src = 'https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8'
    this.playVideo(src)
  }
}
</script>

<style scoped>
  .player {
    position: absolute !important;
    width: 100%;
    height: 60%;
  }
  .vjs-custom-skin {
    height: 60% !important;
  }

  .vjs-custom-skin /deep/ .video-js {
    height: 60%;
  }
</style>


Donate

vue-videojs7 is an MIT licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.

One-time Donations

We accept donations through these channels:

Author

vue-videojs7 © alterhu2020, Released under the MIT License. Authored and maintained by alterhu2020 with help from contributors.

vue-videojs7's People

Contributors

alterhu2020 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-videojs7's Issues

Can't listen to html5 events

Can't listen to html5 events. It works for @play as in the documents for this component, but not for others.

  <video-player ref="video"
                class="vjs-16-9 vjs-big-play-centered vjs-show-big-play-button-on-pause vjs-big-play-hidden"
                :options="playerOptions"
                @timeupdate="updateTime($event)"
                @volumechange="volumenChange($event)"
                @play="playEvent($event)"  // this one actually works
  />

EDITED:
Ouch, I see, the events are listed on the component and I can add global events so they are propagated.

Use with mount as component is not working

The problem

The usage mentioned here is not working for me.

"vue": "2.6.12",
"vue-videojs7": "1.0.2"

When I tried, I get the Vue's unknown component error: [Vue warn]: Unknown custom element: <video-player> - did you register the component correctly?

I Inspected the code and find there is no export for videoPlayer, only as default.

Possible solutions

1. For the author

Add this to vue-videojs7/index.js file:

export { videoPlayer }

2. For users of library

import videojs7 from 'vue-videojs7'
export default {
	components: { videoPlayer: videojs7.videoPlayer }
}

webstrom vue this undefined

你好 请问你的那个 webstrom vue this 指向undefined的问题 是 怎么搞定的?
82467c7f-9157-4f3d-828d-7beda416f789
是这样配置的吗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.