Giter Club home page Giter Club logo

xgplayer-vue's Introduction

Introduction

xgplayer is a web video player library. It has designed a separate, detachable UI component based on the principle that everything is componentized. More importantly, it is not only flexible in the UI layer, but also bold in its functionality: it gets rid of video loading, buffering, and format support for video dependence. Especially on mp4 it can be staged loading for that does not support streaming mp4. This means seamless switching with clarity, load control, and video savings. It also integrates on-demand and live support for FLV, HLS, and dash. Document

xgplayer-vue is the Vue component which encapsulating the xgplayer.

Start

  1. Install

    $ npm install xgplayer-vue@latest
    
  2. Usage

    Step 1. Add xgplayer-vue component

    import Xgplayer from 'xgplayer-vue';
    export default {
      components:{
        Xgplayer
      }
    }

    Step 2. Use in template

    <Xgplayer :config="config" @player="player"/>

    Step 3. Config for xgplayer

    export default {
      data () {
        return {
          config: {
            id: 'vs',
            url: '//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/byted-player-videos/1.0.0/xgplayer-demo.mp4'
          },
          Player: null
        }
      },
      mounted(){
        this.Player.on('ready', ()=>{ console.log('ready') });
        this.Player.on('play', ()=>{ console.log('play') });
        this.Player.on('timeupdate', (player)=>{ console.log(player.currentTime) });
      },
      methods: {
        player(player){
          this.Player = player;
        },
      }
    }

    You can use 'config' object to pre-config xgplayer, such as size, volume, autoplay and so on. More config

    'mp4', 'hls', 'flv', 'dash' are supported to play and you should add the plugin you want to use. Functional Plugins List.

    'Player' is the xgplayer instance which exposed from the component. You can use 'Player' to access the API of xgplayer as follows.

API

Attributes

console.log(this.Player.currentTime)

More attributes

Method

this.Player.pause();

More methods

Event

this.Player.on('play', ()=>{console.log('play')})

More events

Life Cycle

this.Player.once('ready', ()=>{console.log('ready')})

More events

Plugins

xgplayer supports your custom plugins for more content viewing plugins

import Xgplayer from 'xgplayer-vue';
import 'xgplayer-custom';

Demo

$ git clone [email protected]:bytedance/xgplayer-vue.git
$ cd xgplayer-vue
$ npm install
$ npm start

please visit http://localhost:9090/index.html

License

MIT

xgplayer-vue's People

Contributors

zhangxin92 avatar chenguzhen87 avatar xiterjia avatar

Stargazers

 avatar

Watchers

James Cloos 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.