❶ 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播放器。