首页 > 代码库 > vue.js 视频播放

vue.js 视频播放

最近心学习vue.js开发,video开发播放!

使用第三方的封装:https://github.com/hilongjw/vue-video;

1. npm install vue-video --save 安装播放第三方插件;

2.

// script
import myVideo from ‘vue-video‘
export default {
    data () {
        return {
            video: {
                sources: [{
                    src: ‘http://covteam.u.qiniudn.com/oceans.mp4‘,
                    type: ‘video/mp4‘
                }],
                options: {
                    autoplay: true,
                    volume: 0.6,
                    poster: ‘http://covteam.u.qiniudn.com/poster.png‘
                }
            }
        }
    },
    components: {
        myVideo
    }
}


<template>
    <div id="app">
        <div class="container">
            <my-video :sources="video.sources" :options="video.options"></my-video>
        </div>
    </div>
</template>

sources: [{
    // video uri
    src: ‘http://covteam.u.qiniudn.com/oceans.mp4‘,
    // video meta type
    type: ‘video/mp4‘
}]

 

 

options: {
    // autoplay
    autoplay: true,
    // default volume
    volume: 0.6,
    // poster (cover image)
    poster: ‘http://covteam.u.qiniudn.com/poster.png‘
}
 

vue.js 视频播放