js在浏览器中获取本地mp3、wav、mp4音视频文件的大小和时长等数据代码

代码语言:html

所属分类:多媒体

代码描述:js在浏览器中获取本地mp3、wav、mp4音视频文件的大小和时长等数据代码

代码标签: js 浏览器 获取 本地 mp3 wav mp4 音视频 文件 大小 时长 数据 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
   
<meta charset="UTF-8">
   
<meta name="viewport" content="width=device-width, initial-scale=1.0">
   
<title>获取媒体文件时长</title>
   
<style>
       
.container {
           
max-width: 600px;
           
margin: 50px auto;
           
padding: 20px;
           
text-align: center;
       
}
       
.file-input {
           
margin: 20px 0;
       
}
       
.result {
           
margin-top: 20px;
           
padding: 10px;
           
border: 1px solid #ccc;
           
border-radius: 4px;
           
display: none;
       
}
       
.error {
           
color: red;
           
display: none;
       
}
   
</style>
</head>
<body>
   
<div class="container">
       
<h2>获取媒体文件时长</h2>
       
<input type="file" class="file-input" accept="audio/*,video/*" id="fileInput">
       
<div class="result" id="result"></div>
       
<div class="error" id="error"></div>
   
</div>

   
<script>
        const fileInput = document.getElementById('fileInput');
        const resultDiv = docu.........完整代码请登录后点击上方下载按钮下载查看

网友评论0