zoukankan      html  css  js  c++  java
  • vue 视频播放

    1、视频查看按钮:

    <div class="video_btn" @click="showVideo">
      <img style="display: inline-block;vertical-align: middle; 18px;" src="../../assets/software_img/video.png">
      <span>安装视频</span>
    </div>

    2、el-dialog:

    <el-dialog :visible.sync="dialogVisible" width="50%">
      <video
        src="../../assets/software_img/lampBelt.mp4"
        :controls="videoOptions.controls"
        class="video-js vjs-big-play-centered vjs-fluid"
        webkit-playsinline="true"
        playsinline="true"
        x-webkit-airplay="allow"
        x5-playsinline
        style=" 100%;"
        @play="onPlayerPlay"
        @pause="onPlayerPause"
        autoplay="autoplay"
        ref="video">
      </video>
    </el-dialog>

    3、script:

    <script>
        export default {
            name: 'softwareDownload',
            data() {
                return {
                    dialogVisible: false,
                    videoOptions: {
                        controls:true,
                        src: "../../assets/software_img/lampBelt.mp4", // url地址
                    },
                    player: null,
                    playTime:'',
                    seekTime:'',
                    current:'',
                }
            },
            created() {
    
            },
            mounted() {
            },
            beforeDestroy() {
                if (this.player) {
                    this.player.dispose();
                }
            },
            methods: {
                showVideo() {
                    this.dialogVisible = true;
                    this.initVideo();
                },
                initVideo() {
                    //原生初始化视频方法
                    let myVideo = this.$refs.video;
                    //ontimeupdate
                    myVideo = function() {
                        myFunction();
                    };
                    let _this = this;
                    function myFunction(){
                        let playTime = myVideo.currentTime
                        setTimeout(function () {
                            localStorage.setItem("cacheTime",playTime)
                        },500)
                        let time = localStorage.getItem("cacheTime")
                        // 当前播放位置发生变化时触发。
                        if(playTime - Number(time) > 2){
                            myVideo.currentTime = Number(time);
                        } else {
    
                        }
                    };
                },
                // 播放
                onPlayerPlay(player) {
                },
                // 暂停
                onPlayerPause(player) {
                },
            },
        }
    </script>

  • 相关阅读:
    书单
    树莓派与 NATAPP 实现内网穿透
    WinForm分辨率适应-高DPI自动缩放
    ElasticSearch学习——搜索技术基础知识(上)
    JavaSE学习笔记-基础
    JavaSE学习笔记-第一个Java程序
    JavaSE学习笔记-Java开发环境搭建
    MySQL学习笔记-增删改查
    MySQL学习笔记-函数
    MySQL学习笔记-查询
  • 原文地址:https://www.cnblogs.com/moguzi12345/p/14738448.html
Copyright © 2011-2022 走看看