VB 用API 函数如何获取视频音频文件的播放时长

2024-11-29 09:50:35
推荐回答(3个)
回答1:

'获取媒体的长度 00:00
Public Function GetMusicLengthString(FileName As String) As String
Dim RefStr As String * 80
mciSendString "status " & FileName & " length", RefStr, 80, 0
GetMusicLengthString = CStr(Format(Int(Val(RefStr) \ 1000 \ 60), "00") & ":" & Format(Val(RefStr) \ 1000 Mod 60, "00.") & Val(RefStr) \ 100 Mod 10)
End Function

回答2:

Public Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long

回答3:

可以直接通过每秒字节数换算
参考