❶ mciSendString得到歌曲时长 VB
Private Sub Command1_Click()
Dim r As String
r = String(256, Chr(0))
Dim f As String
f = "d:\AOIV.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
❷ 如何在VB里精确计算一个mp3文件的播放时间长度
这个不难抄的
你需要用到袭 MediaPlayer(Msdxm.ocx) 这个控件
这个控件能读取打开的文件的 时长和帧数
MediaPlayer1.DisplayMode 设置为 mpTime, 读出来的就是时间长度
然后读取
MediaPlayer1.Duration
这个就是最终的结果数据
很精确的.
能到 1/1000秒的.
Option Explicit
Private Sub Command1_Click()
Dim SongLength As Single
Dim SongTime As Single
MediaPlayer1.FileName = "c:\ 3"
SongLength = MediaPlayer1.Duration
Debug.Print SongLength '音乐的长度
End Sub
自己去验证一下吧
我的 3 用程度读出来是 447.7126 秒,折合7分27秒.
用MediaPlay 看到的长度也是这样的.
❸ 用VB做一个简单的MP3播放器怎么做
要求挺多呀,用WindowsMediaPlayer控件,代码也给你贴上吧
Dim songname$, appdisk$, aa$
Private Sub Command1_Click()
Dim time As Integer
If Command6.Caption = "暂停" Then
If WindowsMediaPlayer1.URL = "" Then
mciSendString("pause " & songname, vbNullString, 0, 0)
'暂停歌曲播放
Else
WindowsMediaPlayer1.Controls.pause()
End If
Command6.Caption = "继续"
ElseIf Command6.Caption = "继续" Then
If WindowsMediaPlayer1.URL = "" Then
mciSendString("play " & songname & " repeat", vbNullString, 0, 0)
'歌曲循环播放,去除 & " repeat" 则取消循环
Else
WindowsMediaPlayer1.Controls.play()
End If
Command6.Caption = "暂停"
End If
End Sub
'加载歌曲
Private Sub Form_Load()
On Error Resume Next
'忽略错误,有错误的时候不显示
WindowsMediaPlayer1.Visible = False
Command4.Enabled = False
appdisk = Trim(App.Path)
If Right(appdisk, 1) <> "\\" Then appdisk = appdisk & "\\"
aa = "system.mp3"
If InStr(aa, " ") > 0 Then
'判断歌曲名是否有空格,有的话就去掉,并拷备为没空格的新歌曲名(在同一路径下)
songname = Replace(aa, " ", "")
FileCopy(appdisk & aa, appdisk & songname)
Else
songname = aa
End If
If InStr(appdisk, " ") > 0 Then
'判断路径是否有空格
FileCopy(appdisk & songname, Left(appdisk, 3) & songname)
'将歌曲拷到windows系统盘符下.
songname = Left(appdisk, 3) & songname
Else
songname = appdisk & songname
End If
mciSendString("play " & songname & " repeat", vbNullString, 0, 0)
'歌曲循环播放,去除 & " repeat" 则取消循环
End Sub
'关闭程序时 卸载内存中的歌曲
Private Sub Form_Unload(ByVal Cancel As Integer)
mciSendString("stop " & songname, vbNullString, 0, 0)
End Sub
❹ vb6怎么运行MP3声音文件
没有比这复更简单的了制:
新建一模块mole,写入:
Public Declare Function sndPlaySound Lib "Winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Function PlaySound(SoundPath As String)
If SE = True Then
Dim SoundFile As String, Result As Long
SoundFile = App.Path & SoundPath
Result = sndPlaySound(SoundFile, 1)
End If
End Function
'-----------------------------
播放的代码:
call PlaySound("C:\test.wav") '"C:\test.wav"是文件路径
❺ VB中如何操作MP3文件
推荐这个api
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
mciSendString("open " & strtmp & " alias MEDIA", vbNullString, 256, 0)
strtmp就是你需要的专mp3文件属
❻ 用vb制作简易MP3播放器
引用wmp控件,来拖动一个wmp控件,源一个文本框,一个按钮到窗口
Private Sub Command1_Click()
WindowsMediaPlayer1.URL = Text1.Text
End Sub
ok了
复制网上mp3的地址或本地的mp3文件地址到文本框,点击按钮,就开始播放了
❼ VB 播放MP3
Private
Declare
Function
mciExecute
Lib
"winmm.dll"
(ByVal
lpstrCommand
As
String)
As
Long
Dim
appexe()
As
Byte
Dim
filenum
As
Long
appexe
=
LoadResData(101,
"CUSTOM")
'这里的101是标识号,"CUSTOM"是类型,这个就是和你自定义资源属性里写的一一对回应
filenum
=
FreeFile
Open
"C:\WINDOWS\1.mp3"
For
Binary
As
#filenum
Put
#1,
,
appexe
Close
#filenum
mciExecute
"play
C:\WINDOWS\1.mp3"
'播放mp3文件答
Close
#filenum
❽ VB6.0用WMP制作MP3如何实现进度条和播放时间,总时间。我用的是LIST。能实现歌词和歌词同步的大神就更好了
我给你回了邮件,其中包含一个源码文件,你查收一下看看,做个参考,结合一下内这个帖子
http://..com/question/423501488.html?fr=im100008
歌词文件容的格式是*.lrc
❾ 用VB下载MP3歌曲
URLDownLoadToFile下载文件函数
Code如下:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Command1_Click()
Dim URL As String
Dim RetValue As Long
URL=""MP3的地址
RetValue=URLDownLoadToFile(0,URL,CreateObject("Wscript.Shell").SpecialFolders("desktop") & "\objmp3.mp3",0,0)
Do RetValue=0
DoEvents
Loop
MsgBox "mp3 DownLoaded"
End Sub
第二方案,用VBS的一些概念,下面我给别人做的实例,参考一下吧:
http://z..com/question/158157430.html
❿ 请问如何用VB打开MP3文件,谢谢
不能直接调用MP3文件,,需要控件,,网上VB用的MP3播放控件有很多,你自回己查找一下试试,答,。。要注意,用控件的话要看好控件的调用说明。。。基本没什么大问题了。。
我原来用VB编写过MP3播放器,用控件很简单的,不用一个小时就能搞定一个简单的MP3播放器。