iis服务器助手广告广告
返回顶部
首页 > 资讯 > 精选 >vue视频时间进度条组件如何使用
  • 467
分享到

vue视频时间进度条组件如何使用

2023-06-29 17:06:26 467人浏览 独家记忆
摘要

本文小编为大家详细介绍“Vue视频时间进度条组件如何使用”,内容详细,步骤清晰,细节处理妥当,希望这篇“vue视频时间进度条组件如何使用”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。有些视频是以视频流的形式进行渲

本文小编为大家详细介绍“Vue视频时间进度条组件如何使用”,内容详细,步骤清晰,细节处理妥当,希望这篇“vue视频时间进度条组件如何使用”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

有些视频是以视频流的形式进行渲染的,没有视频滚动条,所以就写了24h的时间组件

vue视频时间进度条组件如何使用

vue视频时间进度条组件如何使用

实现思路:

24h的时间刻度线总宽度为12960px
2、点击24h线的某一点,获取这一点离左侧原点的距离(使用dom元素layerX和offsetLeft综合判断)
3、计算点击时线段的占比比率
4、每天的时间是86400000毫秒
5、占比比率乘以86400000就是获取的你点击的时间

代码如下:

<template>  <div class="time-main">    <div class="center-content" ref="centerRef">      <div        ref="timeRef"        class="time-line"        @click.capture="clickTimeLine($event)"      >        <template v-for="(item, i) in timeArr">          <div            :key="'a' + i"            class="base-line"            :          ></div>          <div :key="i" class="base-title" :>            {{ item }}          </div>          <div            :key="'b' + i"            class="base-line"            :          ></div>          <div            :key="'c' + i"            class="base-line"            :          ></div>          <div            :key="'d' + i"            class="base-line"            :          ></div>          <div            :key="'e' + i"            class="base-line"            :          ></div>        </template>      </div>    </div>    <div class="btn-content">      <div class="left-arow" @click="clickRightMove">        <i class="el-icon-arrow-left"></i>      </div>      <div>{{ yesterdayTime | fORMatDateTime }}</div>      <div class="right-arow" @click="clickLeftMove">        <i class="el-icon-arrow-right"></i>      </div>    </div>  </div></template><script>import {  compare,  exactDiv,  exactMul,  exactSub,  exactAdd,  decimalsFormat,} from "@/util/util.js";export default {  name: "timeLine",  // inject: ["screenNum"],  // watch: {  //   screenNum: {  //     handler(val) {  //       console.log("切换了val==", val);  //     },  //   },  // },  props: {    dateArr: {      type: Array,    },  },  data() {    return {      clickCnt: 0,      leftMoveWidth: 0,      endTimeFlag: false,      timeArr: [        "00:00",        "00:10",        "00:20",        "00:30",        "00:40",        "00:50",        "01:00",        "01:10",        "01:20",        "01:30",        "01:40",        "01:50",        "02:00",        "02:10",        "02:20",        "02:30",        "02:40",        "02:50",        "03:00",        "03:10",        "03:20",        "03:30",        "03:40",        "03:50",        "04:00",        "04:10",        "04:20",        "04:30",        "04:40",        "04:50",        "05:00",        "05:10",        "05:20",        "05:30",        "05:40",        "05:60",        "06:00",        "06:10",        "06:20",        "06:30",        "06:40",        "06:50",        "07:00",        "07:10",        "07:20",        "07:30",        "07:40",        "07:50",        "08:00",        "08:10",        "08:20",        "08:30",        "08:40",        "08:50",        "09:00",        "09:10",        "09:20",        "09:30",        "09:40",        "09:50",        "10:00",        "10:10",        "10:20",        "10:30",        "10:40",        "10:50",        "11:00",        "11:10",        "11:20",        "11:30",        "11:40",        "11:50",        "12:00",        "12:10",        "12:20",        "12:30",        "12:40",        "12:50",        "13:00",        "13:10",        "13:20",        "13:30",        "13:40",        "13:50",        "14:00",        "14:10",        "14:20",        "14:30",        "14:40",        "14:50",        "15:00",        "15:10",        "15:20",        "15:30",        "15:40",        "15:50",        "16:00",        "16:10",        "16:20",        "16:30",        "16:40",        "16:50",        "17:00",        "17:10",        "17:20",        "17:30",        "17:40",        "17:50",        "18:00",        "18:10",        "18:20",        "18:30",        "18:40",        "18:50",        "19:00",        "19:10",        "19:20",        "19:30",        "19:40",        "19:50",        "20:00",        "20:10",        "20:20",        "20:30",        "20:40",        "20:50",        "21:00",        "21:10",        "21:20",        "21:30",        "21:40",        "21:50",        "22:00",        "22:10",        "22:20",        "22:30",        "22:40",        "22:50",        "23:00",        "23:10",        "23:20",        "23:30",        "23:40",        "23:50",      ],      switchWidthNum: 540,      yesterdayTime: 0,      clickTimeVal: 0,    };  },  mounted() {    // this.handleWidthFn();    this.dealScrollMove();    // console.log("mounted==", this.dateArr);  },  methods: {    dealScrollMove() {      if (this.$refs.centerRef.offsetWidth >= 540) {        this.switchWidthNum = 540;      } else if (this.$refs.centerRef.offsetWidth >= 360) {        this.switchWidthNum = 360;      } else if (this.$refs.centerRef.offsetWidth >= 270) {        this.switchWidthNum = 270;      } else if (this.$refs.centerRef.offsetWidth >= 180) {        this.switchWidthNum = 180;      } else {        this.switchWidthNum = 90;      }      let time0 = new Date(new Date().toLocaleDateString()).getTime(); //获取当日0点时间戳      let time1 = new Date().getTime(); // 当前时间      let sumTimeWidth = 12960;      let dayTimeSum = 86400000; //一天的毫秒数      // if (this.clickTimeVal) {      //   time1 = this.clickTimeVal;      //   console.log("进==", time1);      //   console.log("进=2=", this.clickTimeVal);      // }      if (this.dateArr.length > 0) {        time1 = this.dateArr[0];        time0 = exactSub(time0, dayTimeSum);        console.log("进==", this.dateArr);        console.log("进=2=", this.clickTimeVal);      }      let timeSub = exactSub(time1, time0);      // console.log("timeSub=", timeSub);      if (this.dateArr.length > 0) {        this.yesterdayTime = this.dateArr[0];        this.clickTimeVal = this.dateArr[0];      } else {        this.yesterdayTime = exactSub(time0, dayTimeSum);      }      let dayPer = exactDiv(timeSub, dayTimeSum); //一天的百分比      console.log("exactDiv(timeSub, dayTimeSum)==", this.yesterdayTime);      // console.log("dayPer==", dayPer);      let scrollWidth = exactMul(sumTimeWidth, dayPer);      // console.log("scrollWidth=333333=", scrollWidth);      // console.log("scrollWidth=33333555553=", this.switchWidthNum);      // 除以switchWidthNum 获取点击的个数      let switchClickCnt = exactDiv(scrollWidth, this.switchWidthNum);      // console.log("switchClickCnt==", switchClickCnt);      this.clickCnt = parseInt(switchClickCnt) - 1;      this.clickLeftMove();      // console.log("点击的数量1===", this.clickCnt);    },    handleWidthFn() {      this.$nextTick(() => {        if (this.$refs.centerRef.offsetWidth >= 540) {          this.switchWidthNum = 540;        } else if (this.$refs.centerRef.offsetWidth >= 360) {          this.switchWidthNum = 360;        } else if (this.$refs.centerRef.offsetWidth >= 270) {          this.switchWidthNum = 270;        } else if (this.$refs.centerRef.offsetWidth >= 180) {          this.switchWidthNum = 180;        } else {          this.switchWidthNum = 90;        }      });    },    clickTimeLine(event) {      // console.log("event==", event);      // console.log("event=layerX==", event.layerX);      // console.log("event=layerX=target===", event.target.offsetLeft);      let sumTimeWidth = 12960;      let dayTimeSum = 86400000; //一天的毫秒数      let time0 = new Date(new Date().toLocaleDateString()).getTime(); //获取当日0点时间戳      let yesterdayTime = exactSub(time0, dayTimeSum);      let timePointNum = 0;      // className: "time-line"      if (event.target.className == "time-line") {        timePointNum = event.layerX;      } else {        timePointNum = exactAdd(event.layerX, event.target.offsetLeft);      }      let timemove = exactAdd(timePointNum, this.leftMoveWidth);      let timePer = exactDiv(timemove, sumTimeWidth); // 点击的百分比      let clickTimeNum = exactMul(dayTimeSum, timePer); //      let trueTimeNum = exactAdd(clickTimeNum, yesterdayTime); // time      let fomretTime = parseInt(trueTimeNum);      this.clickTimeVal = new Date(fomretTime).getTime();      this.$emit(        "handleClickTimeLineFn",        new Date(fomretTime)      );      // console.log("trueTimeNum==", trueTimeNum);      // console.log("fomretTime==", fomretTime);      // console.log("new Date==", new Date(fomretTime));    },    clickLeftMove() {      // console.log("点击的数量==2=", this.clickCnt);      this.handleWidthFn();      // console.log("this.$refs.centerRef==", this.$refs.centerRef);      // console.log("centerRef=offsetWidth=", this.$refs.centerRef.offsetWidth);      // console.log("centerRef=clientWidth=", this.$refs.centerRef.clientWidth);      if (this.endTimeFlag) {        return;      }      this.clickCnt++;      this.leftMoveWidth = this.clickCnt * this.switchWidthNum;      let letWidth = this.clickCnt * this.switchWidthNum + "px";      // console.log(this.clickCnt);      // console.log("this.$refs.timeRef==", this.$refs.timeRef);      if (this.leftMoveWidth + this.$refs.centerRef.offsetWidth > 12960) {        letWidth = 12960 - this.$refs.centerRef.offsetWidth + "px";        this.endTimeFlag = true;      } else {        this.endTimeFlag = false;      }      this.$refs.timeRef.style.transform = "translateX(-" + letWidth + ")";      this.$refs.timeRef.style.transition = "all 0.5s";    },    clickRightMove() {      this.handleWidthFn();      if (this.clickCnt > 0) {        this.clickCnt--;      }      this.leftMoveWidth = this.clickCnt * this.switchWidthNum;      let letWidth = this.clickCnt * this.switchWidthNum + "px";      // console.log(this.clickCnt);      // console.log("this.$refs.timeRef==", this.$refs.timeRef);      if (this.endTimeFlag) {        this.endTimeFlag = false;      }      this.$refs.timeRef.style.transform = "translateX(-" + letWidth + ")";      this.$refs.timeRef.style.transition = "all 0.5s";    },  },};</script><style scoped lang="sCSS">.time-main {  position: relative;  width: 100%;  margin: auto;  overflow: hidden;  // display: flex;  //   border: 1px solid red;}.center-content {  width: calc(100% - 30px);  margin-left: 30px;  overflow: hidden;}.btn-content {  width: calc(100% - 30px);  margin-left: 30px;  display: flex;  justify-content: space-between;  color: #fff;}.time-line {  position: relative;  font-size: 12px;    //   left: 30px;  height: 19px;  width: 12960px;  border-bottom: 1px solid rgb(90, 90, 90);  margin: 0px;  padding: 0px;  transition: left 0.9s ease 0s;  color: #fff;  z-index: 10;  &:hover {    cursor: pointer;  }  .base-title {    position: absolute;    left: 4px;    bottom: 3px;    color: #fff;    z-index: -1;  }}.base-line {  position: absolute;  width: 1px;  height: 4px;  bottom: 0px;  background-color: rgb(90, 90, 90);  z-index: 9;}.left-arow {  // position: absolute;  // left: 2%;  color: #fff;  font-size: 20px;}.right-arow {  // position: absolute;  // right: 2%;  color: #fff;  font-size: 20px;}</style>

读到这里,这篇“vue视频时间进度条组件如何使用”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注编程网精选频道。

--结束END--

本文标题: vue视频时间进度条组件如何使用

本文链接: https://www.lsjlt.com/news/326001.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • vue视频时间进度条组件如何使用
    本文小编为大家详细介绍“vue视频时间进度条组件如何使用”,内容详细,步骤清晰,细节处理妥当,希望这篇“vue视频时间进度条组件如何使用”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。有些视频是以视频流的形式进行渲...
    99+
    2023-06-29
  • vue视频时间进度条组件使用方法详解
    本文实例为大家分享了vue视频时间进度条组件的使用方法,供大家参考,具体内容如下 有些视频是以视频流的形式进行渲染的,没有视频滚动条,所以就写了24h的时间组件 实现思路: 1、...
    99+
    2024-04-02
  • vue2.0如何实现音乐/视频播放进度条组件
    这篇文章主要为大家展示了“vue2.0如何实现音乐/视频播放进度条组件”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“vue2.0如何实现音乐/视频播放进度条组件...
    99+
    2024-04-02
  • Vue如何实现简单的时间轴与时间进度条
    目录前言1、封装时间尺度组件2、在vue页面使用时间尺度 3、组件init方法内 通过起止时间算出中间的所有时间尺度 总结前言 项目需要按天播放地图等值...
    99+
    2024-04-02
  • vue如何实现实时上传文件进度条
    这篇文章主要介绍了vue如何实现实时上传文件进度条,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。具体内容如下//上传文件组件<el-upload  ...
    99+
    2023-06-29
  • 如何实现python爬虫爬取视频时实现实时进度条显示
    目录一、全部代码展示二、解释1.with closingwith用法(实现上下文管理)closing用法(完美解决上述问题)2.文件流stream3.response.headers...
    99+
    2024-04-02
  • MFC进度条控件如何使用
    MFC进度条控件可以通过以下步骤来使用:1. 在资源编辑器中添加一个进度条控件。可以通过拖放的方式将进度条控件添加到对话框或窗口中。...
    99+
    2023-09-15
    MFC
  • 如何解决Html5中视频、音频标签的进度条问题
    这篇文章主要为大家展示了“如何解决Html5中视频、音频标签的进度条问题”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何解决Html5中视频、音频标签的进度条...
    99+
    2024-04-02
  • amazeui如何使用时间组件
    这篇文章给大家分享的是有关amazeui如何使用时间组件的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。一、总结一句话总结:图标是字体样式:input右侧的字体图标是字体样式,所以要引入字体文件,随便找一个项目把里...
    99+
    2023-06-09
  • 如何使用PHP进行视频文件处理?
    视频文件处理是现代网络应用程序中必不可少的一部分,它包括裁剪、压缩、转码、添加水印和合并等操作。PHP 作为一种流行的服务器端编程语言,可以用于处理这些要求。在本文中,我们将介绍如何使用 PHP 处理视频文件。安装 FFMPEG 库FFMP...
    99+
    2023-05-14
    PHP 视频文件处理 处理技巧
  • Vue中render如何实现渲染时间戳转时间以及渲染进度条效果
    这篇文章给大家分享的是有关Vue中render如何实现渲染时间戳转时间以及渲染进度条效果的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。一.格式化时间效果图:实现上述界面代码如下:...
    99+
    2024-04-02
  • vue组件间如何进行通信
    本篇内容介绍了“vue组件间如何进行通信”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!vue是数据驱动视图更新的框架, 我们平时开发,都会把...
    99+
    2023-06-21
  • python如何实现带时间的普通进度条
    小编给大家分享一下python如何实现带时间的普通进度条,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!带时间的普通进度条第2种同...
    99+
    2024-04-02
  • 使用Compose制作抖音快手视频进度条Loading动画效果
    目录引言Loading效果BoxWithConstraints代码animateFloat获取动画更新值线条动画值执行渐隐最终效果引言 现在互联网产品,感觉谁家的App不整点视频功能...
    99+
    2024-04-02
  • vue时间线组件的使用方法
    本文实例为大家分享了vue时间线组件的具体实现代码,供大家参考,具体内容如下 效果 vue-时间线组件(时间轴组件)代码 <template> <ul...
    99+
    2024-04-02
  • Vue中如何使用echarts可视化组件
    这篇文章将为大家详细讲解有关Vue中如何使用echarts可视化组件,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。找到脚手架项目所在地址,执行cnpm install echarts,安装e...
    99+
    2023-06-20
  • react-player如何实现视频播放与自定义进度条效果
    这篇文章将为大家详细讲解有关react-player如何实现视频播放与自定义进度条效果,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。环境react.js   ant de...
    99+
    2023-06-28
  • 如何使用PHP进行视频处理?
    随着网络技术的飞速发展,视频已经成为人们日常生活中不可或缺的一部分。在这个数字时代,如何使用PHP进行视频处理已经成为了一个热门话题,本文将介绍PHP的一些基本功能和工具,以帮助大家更好地处理视频。一、认识PHPPHP是一种高级程序设计语言...
    99+
    2023-05-22
    PHP 视频处理 多媒体应用
  • vue如何实现页面加载时的进度条功能
    这篇文章将为大家详细讲解有关vue如何实现页面加载时的进度条功能,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。先看一张图如果我们的程序每次页面切换时,顶部也有一个进度条,...
    99+
    2024-04-02
  • python如何使用tqdm制作进度条
    这篇文章主要介绍了python如何使用tqdm制作进度条,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。使用tqdm制作进度条TQDM库使你可以为Python和CLI创建快速地...
    99+
    2023-06-27
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作