| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 957 人关注过本帖
标题:VB6获取音频时长,获取的不准确怎么回事?
取消只看楼主 加入收藏
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:30
帖 子:1693
专家分:2588
注 册:2009-12-22
结帖率:88.1%
收藏
 问题点数:0 回复次数:1 
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
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:30
帖 子:1693
专家分:2588
注 册:2009-12-22
收藏
得分:0 
来,测试一下。
1.zip (420.04 KB)

心生万象,万象皆程序!
2022-07-30 16:29
快速回复:VB6获取音频时长,获取的不准确怎么回事?
数据加载中...
 
   



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

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