<template>
    <div class="app-rawitem-video">
        <video :src="playerParams.url" :autoplay="playerParams.autoplay" :controls="playerParams.controls"
            :loop="playerParams.loop" :muted="playerParams.volume">
        </video>
    </div>
</template>

<script lang="ts">
import { Util } from '@/utils';
import { Component, Vue, Prop } from 'vue-property-decorator';
@Component({})
export default class AppVideo extends Vue {
    /**
     * 播放器唯一标识
     */
    public uuid: string = Util.createUUID();

    /**
     * 视频播放数据
     */
    @Prop() public videoParmas?: any;

    //视频播放参数
    public playerParams = {
        id: this.uuid,
        height: '100%',
        width: '100%',
        url: "",
        volume: 0.8,
        autoplay: false,
        loop: false,
        controls: false
    };


    /**
     * 生命周期
     */
    public mounted() {
        this.handleStaticVideo();
    }

    /**
     * 处理静态视频播放
     *
     * @memberof AppPresetRawitem
     */
    protected handleStaticVideo() {
        if (this.videoParmas && this.videoParmas.length > 0) {
            const rawParams:any = {};
            this.videoParmas.forEach((param: any) => {
                rawParams[param.key] = param.value;
            })
            Object.assign(this.playerParams,rawParams);
        }
    }
}
</script>

<style lang='less'>
@import "./app-rawitem-video.less";
</style>
