标题:VB6获取音频时长,获取的不准确怎么回事?
只看楼主
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册:2009-12-22
结帖率:89.13%
 问题点数:0 回复次数:4 
VB6获取音频时长,获取的不准确怎么回事?
VB6用API 函数获取视频音频文件的播放时长

程序代码:
Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Public Function GetMusicLengthString(FileName As String) As String
Dim RefStr As String * 80
mciSendString "status " & FileName & " length", RefStr, 80, 0
GetMusicLengthString = RefStr
End Function

Private Sub Form_Load()
MsgBox GetMusicLengthString("E:\1.mp3")
End Sub


程序代码:
Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Sub Form_Load()
Dim r As String
r = String(256, Chr(0))
Dim f As String
f = "E:\1.mp3" '文件名根据自己需要改
mciSendString "Status " & f & " length", r, 256, 0
Dim m As Long
m = Val(r) \ 1000 \ 60
Dim c As Double
c = Val(r) / 1000 - m * 60
MsgBox "长度" & m & "" & c & ""
End Sub
搜索更多相关主题的帖子: 获取 String Long ByVal Dim 
2022-07-30 14:17
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:0 
准确的是多少
程序显示的是多少
2022-07-30 16:22
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册:2009-12-22
得分:0 
来,测试一下。
1.zip (420.04 KB)

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2022-07-30 16:29
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:0 
回复 3楼 yuma

从ID3V2看是ID3v2.4,播放软件一般只支持ID3v2.3

[此贴子已经被作者于2022-7-31 08:30编辑过]

2022-07-31 08:28
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:0 
转用均衡比特率编码(或固定码率)显示的时长正常
11.rar (413.57 KB)
2022-07-31 11:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-509681-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.067638 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved