Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-video-player

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-video-player

Video Player component for Vue.js(1.x ~ 2.x)

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7K
decreased by-34.6%
Maintainers
1
Weekly downloads
 
Created
Source

GitHub issues GitHub forks GitHub stars Twitter

NPM

Vue-Video-Player

Video/Live player for Vue.js(1.x ~ 2.x) 基于 video.js + videojs-resolution-switcher + videojs-contrib-hls

  • [增加]:可以配置在IOS(非safari)环境下,默认播放是否全屏
  • 支持HlS流媒体(.m3u8)直播、各种普通类型视频
  • 普通视频可支持多种分辨率切换
  • 普通视频可支持多种播放速度切换
  • 可根据环境自动降级为flash播放
  • 可播放Youtube视频
  • 支持Vue.js(1.x ~ 2.x)全版本
  • 基于Video.js有丰富的API和文档支持

Example

Demo Page

Use Setup

Install vue-video-player

npm install vue-video-player --save
// import with ES6
import Vue from 'vue'
...
import VideoPlayer from 'vue-video-player'


// require with Node.js/Webpack
var Vue = require('vue')
...
var VideoPlayer = require('vue-video-player')

// use
Vue.use(VideoPlayer)

// --------------------------------------


// or use with component(ES6)
import Vue from 'vue'
// ...
import { videoPlayer } from 'vue-video-player'

// use
export default {
  components: {
    videoPlayer
  }
}
<!-- Use in component(Vue.js1.X) -->
<video-player :options="videoOptions"></video-player>

<!-- Use in component(Vue.js2.X) -->
<video-player :options="videoOptions" @playerStateChanged="playerStateChanged"></video-player>

<!-- parent component to control the player do something -->
<button @click="playerAction('play')">Play</button>
<button @click="playerAction('pause')">Pause</button>
<button @click="playerAction('refresh')">Refresh</button>
// component config example 1(video)
export default {
  data () {
    return {
       videoOptions: {
        source: {
          type: "video/webm", 
          src: 'https://cdn.theguardian.tv/webM/2015/07/20/150716YesMen_synd_768k_vp8.webm'
        }
      }
    }
  }
}


// component config example 2(video)
export default {
  data () {
    return {
      videoOptions: {
        source: [
          { type: "video/mp4", src: 'http://example.com/sample_video_H.mp4', label: '原画', res: 1 },
          { type: "video/mp4", src: 'http://example.com/sample_video_M.mp4', label: '高清', res: 2 },
          { type: "video/mp4", src: 'http://example.com/sample_video_L.mp4', label: '流畅', res: 3 }
        ],
        language: 'zh-CN',
        playbackRates: [0.7, 1.0, 1.3, 1.5, 1.7],
        poster: 'http://cn.vuejs.org/images/logo.png',
        defaultSrcReId: 2
      }
    }
  }
}


// component config example 3(live)
export default {
  data () {
    return {
       videoOptions: {
        source: {
          type: 'application/x-mpegURL',
          src: 'https://example.net/live/playlist.m3u8',
          withCredentials: false
        },
        live: true,
        // IOS微信内置浏览器默认播放不全屏
        playsinline: true
      }
    }
  }
}

//-------------------------------------------------------------

// playerStateChanged callback example(Vue.js1.X)
export default {
  events: {
    'playerStateChanged': function (playerCurrentState) {
      console.log(playerCurrentState)
    }
  }
}


// playerStateChanged callback example(Vue.js2.X)
export default {
  methods: {
    playerStateChanged(playerCurrentState) {
      console.log(playerCurrentState)
    }
  }
}

//-------------------------------------------------------------

// playerAction event example(Vue.js1.X)
export default {
  methods: {
    playerAction: function(action) {
      this.$broadcast('playerAction', action)
    }
  }
}


// playerAction event example(Vue.js2.X)
export default {
  methods: {
    playerAction(action) {
      this.$emit('playerAction', action)
    }
  }
}

More Code Example

API

protypetypedescriptionexample
playsinlineBooleanthe player default play auto fullscreen in IOS(!safari) (Y/n) default: true
sourceObject/Arraythe player source src(required)
mutedBooleandefault: false
autoplayBooleandefault: true
startNumberplayer start time(default: 0)
liveBooleanplayer is live?
playbackRatesArrayplayer play backrates[0.7, 1.0, 1.3, 1.5, 1.7]
defaultSrcReIdNumber当有多个资源时,用于指定默认播放哪一种(分辨率)资源(default: 1)
controlsBooleanplayer controls display or hidden
preloadBooleanplayer preload ?
posterStringplayer poster(default: '')'http://adasd.jpg' / 'data:image/png;base64,iVB...'
wdithNumberplayer width (default: 100%)
heightNumberplayer width (height: 360)
controlBarObjectplayer controlBar dsipaly configneed to video.js api doc
languageStringplayer language(default: 'en')
techOrderArrayplayer support video type (default: example)['html5', 'flash', 'youtube']

Credits

video.js

video.js api

videojs-resolution-switcher

videojs-contrib-hls

Author Blog

Surmon

Keywords

FAQs

Package last updated on 10 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc