In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to get the video duration in the vue project". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to obtain the video duration in the vue project".
Vue acquires video duration
The input parameter is the video file object
The code for js is as follows:
GetVideoDuration (file) {var url = URL.createObjectURL (file); var audioElement = new Audio (url); var self = this; var result; audioElement.addEventListener ("loadedmetadata", function () {/ / the video duration value will not be obtained until the execution of this anonymous function completes to generate result = audioElement.duration; / / get the duration in seconds, decimal, 182.36 self.ruleForm.videoDuration = parseInt (result); / / convert to int value}) } vue-video-player get playback time npm install vue-video-player-S global reference import VideoPlayer from 'vue-video-player'import' vue-video-player/src/custom-theme.css'import 'video.js/dist/video-js.css'Vue.use (VideoPlayer) local reference import {videoPlayer} from' vue-video-player'import 'video.js/dist/video-js.css' export default {components: {videoPlayer} } html methods get playback time this.$nextTick (() = > {setTimeout () = > {let du = document.getElementById ("vjs_video_3_html5_api") / / get video var hour = parseInt ((du.duration) / 3600) under the component Var minute = parseInt ((du.duration% 3600) / 60); var second = parseInt (du.duration% 60) Let result =''if (hour > 0) {result = this.formatTimeStr (hour) +':'+ this.formatTimeStr (minute) +':'+ this.formatTimeStr (second)} else {result = this.formatTimeStr (minute) +':'+ this.formatTimeStr (second)} Return result / / transformed components Second}, 200)}) formatTimeStr (val) {if (val > 9) {return val} else {return'0' + val}}, thank you for reading. This is the content of "how to get the video duration in the vue project". After the study of this article I believe you have a deeper understanding of how to obtain the duration of the video in the vue project, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.