vue-video-player


目录
  • vue-video-player
  • 视频托管

vue-video-player

安装:

npm install vue-video-player -S

在main.js导入:

// vue-video播放器
require('video.js/dist/video-js.css');
require('vue-video-player/src/custom-theme.css');
import VideoPlayer from 'vue-video-player'
Vue.use(VideoPlayer);

某个vue组件中(script标签导入):

import { videoPlayer } from 'vue-video-player'
import 'video.js/dist/video-js.css'

export default {
  components: {
    videoPlayer
  }
}

template标签中:


js:

export default {
    data() {
        return {
            playerOptions: {
                playbackRates: [0.5, 1.0, 1.5, 2.0], // 可选的播放速度
                autoplay: false, // 如果为true,浏览器准备好时开始回放。
                muted: false, // 默认情况下将会消除任何音频。
                loop: false, // 是否视频一结束就重新开始。
                preload: 'auto', // 建议浏览器在

视频托管

第三方托管:七牛云 - 产品主页 (qiniu.com)

自己搭建存储服务器

  • fastdfs:教程:https://zhuanlan.zhihu.com/p/372286804
  • Minio:教程:

七牛云上传

# pip install qiniu
from qiniu import Auth, put_file, etag
import qiniu.config
#需要填写你的 Access Key 和 Secret Key
access_key = ''
secret_key = ''
#构建鉴权对象
q = Auth(access_key, secret_key)
#要上传的空间
bucket_name = ''
#上传后保存的文件名
key = 'my-python-logo.png'
#生成上传 Token,可以指定过期时间等
token = q.upload_token(bucket_name, key, 3600)
#要上传文件的本地路径
localfile = './致命诱惑.mp4'
ret, info = put_file(token, key, localfile, version='v2')
print(info)
assert ret['key'] == key
assert ret['hash'] == etag(localfile)
vue