video.vue 1.7 KB
<template>
    <div class="video-box">
        <el-dialog title="录像" :visible.sync="videoDialogVisible">
            <video id="playerVideo" class="dom-video" controls muted></video>
            <div slot="footer" class="player-footer">
                <button @click="closeVideoDialog">关闭</button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import {config} from '../../public/js/config'
    export default {
        data () {
            return {
                videoDialogVisible: false,
                domTimer: null,
                player: ''
            }
        },
        methods: {
            playvideos: function (play_url) {
                let _this = this;
                this.videoDialogVisible = true;
                this.domTimer = setTimeout(() => {
                    this.player = document.getElementById('playerVideo');
                    console.log(this.player)
                    this.player.loop = true;
                    if(config.https) {
                     let loc = location.host
                     this.player.src = `https://${loc}/${play_url.split(":20080")[1]}`
                    } else {
                    this.player.src = play_url;
                    }
                    this.player.play();
                }, 100);
            },
            closeVideoDialog: function () {
                this.domTimer = null;
                this.player.src = '';
                this.player = '';
                this.videoDialogVisible = false;
            }
        }
    }
</script>

<style scoped>
    .dom-video {
        width: 100%;
        height: 100%;
        border-radius: 5px;
    }

    .player-footer button {
        padding: 0 2%;
    }
</style>