Giter VIP home page Giter VIP logo

vue-videojs's Introduction

vue-videojs

基于videojs的封装,方便使用,无污染

安装

npm install video.js vue-videojs -S

引入vue-video组件

import VVideo from 'vue-videojs'
// use global
Vue.use(VVideo);

// or use in component .vue
components: {
  VVideo
}

使用

<style lang="scss">
  .video-js {
    width: 600px;
    height: 400px;
  }
</style>
<template>
  <div id="app">
    <v-video ref="video" width="600" height="400"
         poster="//vjs.zencdn.net/v/oceans.png"
         class="video-js"
         webkit-playsinline
         playsinline
         x-webkit-airplay="allow"
         x5-video-player-type="h5"
         x5-video-player-fullscreen="true"
         x5-video-orientation="portraint"
         controls :sources="videos" :options="playOpts.options" @ready="videoReady" @ended="videoEnd"></v-video>
  </div>
</template>
<script>
export default {
  name: 'app',
  data () {
    return {
      videos: [
        'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
      ],
      playOpts: {
        options: {
          controls: true,
          // autoplay: true,
          preload: 'auto',
          techOrder: ["html5"]
          // aspectRatio: "16:9"   // 配置了这个,class设置的样式无效
        }
      }
    }
  },
  methods: {
    videoEnd () {
      console.log('video end');
    },
    videoReady () {
      var video = this.$refs.video.videojsObject;
      // video.play();
    }
  }
}
</script>

怎么videojs获取实例对象?

在ready回调里可以通过 this.$refs.video.videojsObject; 来获取videojs的实例对象

vue-videojs's People

Contributors

kelen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.