1. 用vb怎樣製作音樂播放器啊
好的,我們的教程現在開始——————
這個是我已經做好了的窗體,來看一下,這個應該熟悉吧?就是windows media player 它是怎麼添加的呢?呵呵,其實很簡單的哦,認真看我的操作,選中這個,因為我已經選擇好了,有這個是不行的,還要添加一個空間,那就是commondialog,它的添加給media player一樣的,Microsoft Common Dialog Control 6.0 選中這個就行了,它對應的圖標是這個————看我滑鼠。把這個兩個再添加到窗體上就可以了。
然後就是寫代碼,我想你是想做個播放器吧?呵呵,我就把代碼順便給你寫了出來....下面看代碼
'代碼開始————————————————————
Private Sub Command1_Click()
CommonDialog1.Action = 1
WindowsMediaPlayer1.URL = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Form1.Caption = "影音播放器"
Command1.Caption = "打開"
Command2.Caption = "退出"
End Sub
_________________________________________________
這個就是代碼了,下面我們運行一下看能不能運行啊...期待中ing...o(∩_∩)o...貌似可以哦,^_^
:-),看到沒,一個播放器做成了!!!怎麼樣?有點成就感吧?當然要做好一個播放器不只是這么簡單的哦,還需要繼續努力!好了,教程到此結束.我這個支持你選擇播放的!!!
以上程序在xp下測試通過!
2. VB中的Windows Media Player控制項,如何播放本地音樂
具體步驟來如下:
1、建立一個空窗自體。
2、加入WindowsMediaPlayer控制項(也可以完全由代碼生成),更名為Player
3、加入兩個命令按鈕:cmdPlay,cmdStop
4、sub cmdPlay_Clicked:
With Player
.uiMode = "none"
.URL = "D:/MUSIC/雨人.wma"
.Controls.Play
End With
5、sub cmdStop_Clicked:
Player.Controls.Stop
3. 用VB做個音樂播放器
工程-->部件-->瀏覽-->選擇msdxm.ocx載入
然後在窗體設計器中創建一個MediaPlayer控制項,名字不用改,不過注意如果專名字不是屬MediaPlayer1就說明該控制項版本和我不一樣,代碼也就不能用了。
接著在Form_load事件中加入代碼:
MediaPlayer1.AutoStart = False '讓播放器不自動播放
MediaPlayer1.FileName = "C:\123.mp3" '載入C:\123.mp3
MediaPlayer1.Play '播放
當然事先要在C盤放一個123.mp3
暫停和停止功能,MediaPlayer控制項自帶。
雖然功能很少但是至少可以實現mp3播放,如果你有不懂的地方,我可以繼續為你解答。
4. 如何用VB編寫一個音樂播放器
添加一個 WindowsMediaPlayer,一個CommonDialog,一個list ,一個command
Dim pa As String
Private Sub Command1_Click()
Dim song As String
With CommonDialog1
.FileName = ""
.Filter = "*.MP3|*.mp3;*.avi;*.mid"
.Flags = 512
.ShowOpen
song = .FileName
End With
If song = "" Then Exit Sub
a = ""
For i = Len(song) To 1 Step -1
k = Mid(song, i, 1)
If k = " " Then '多首歌的分隔符
List1.AddItem a
a = ""
ElseIf k = "\" Then '一首歌時歌名與路徑的分隔符
List1.AddItem a
pa = Left(song, i)
Exit Sub
Else
a = k & a
End If
Next i
End Sub
Private Sub List1_DblClick()
Me.Caption = "我的播放器 當前播放" & pa & List1.Text
WindowsMediaPlayer1.URL = pa & List1.Text
End Sub
5. vb中的音樂播放器用list如何添加歌曲 急求
With CommonDialog1
.FileName = ""
.InitDir = App.Path
.CancelError = True
.Filter = "音樂文件(*.mp3)|*.mp3"
.ShowOpen
End With
List1.AddItem CommonDialog1.FileName
6. vb.net中編輯音樂播放器用什麼控制項添加音樂
需要用到COM控制項,例如media player、Real player等,或者用 .NET 自帶的類庫 System.Media下面的 SoundPlayer來播放音樂
7. VB如何播放背景音樂
兄弟 代碼較多 你可以給出郵箱嗎?我直接發給你源碼。不過如果你不需要所有的功能你可以參考下面的代碼。只是部分,因為還有一個模塊沒有。
Dim ier As Boolean
Private Sub Command1_Click()
If Command1.Caption = "暫停播放" Then
WindowsMediaPlayer1.Controls.pause
Command1.Caption = "接著播放"
ipause.Caption = "接著播放"
ElseIf Command1.Caption = "接著播放" Then
WindowsMediaPlayer1.Controls.play
Command1.Caption = "暫停播放"
ipause.Caption = "暫停播放"
End If
End Sub
Private Sub Command2_Click()
Call rPlayMusic
End Sub
Private Sub Command3_Click()
'播放下一首
If File1.ListIndex < File1.ListCount - 1 Then
File1.ListIndex = File1.ListIndex + 1
ElseIf File1.ListIndex = File1.ListCount - 1 Then
File1.ListIndex = 0
End If
Call play(File1.Path & "\" & File1.FileName)
End Sub
Private Sub Command4_Click()
Me.Hide
End Sub
Private Sub File1_DblClick()
Call play(App.Path & "\music\" & File1.FileName)
End Sub
Private Sub Form_Load()
'添加托盤圖標
Call AddIcon
'label1動態初始化
ier = True
'播放器處理
WindowsMediaPlayer1.uiMode = "invisible"
WindowsMediaPlayer1.Controls.stop
'播放文件夾處理
On Error Resume Next '避開錯誤處理直接生成music文件甲
MkDir (App.Path & "\music")
'定義當前音樂文件播放地址 用filelist直接取得
File1.Path = App.Path & "\music"
'隨機播放音樂
Call rPlayMusic
End Sub
Private Sub rPlayMusic()
Dim i As Integer
Randomize
i = Int(Rnd * File1.ListCount) '取得一個屬於音樂文件的標識
File1.ListIndex = i
Call play(File1.Path & "\" & File1.FileName) '播放路徑名中音樂文件
End Sub
Private Sub play(mPlay As String)
WindowsMediaPlayer1.Controls.stop
WindowsMediaPlayer1.URL = mPlay
WindowsMediaPlayer1.Controls.play
a = Split(mPlay, "\")
a = a(UBound(a))
Label1.Caption = "現在正在播放:" & a
ier = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call DelIcon '刪除托盤圖標
WindowsMediaPlayer1.Controls.stop
Unload Me
End Sub
Private Sub iend_Click()
Unload Me
End Sub
Private Sub inext_Click()
Call Command3_Click
End Sub
Private Sub ipause_Click()
Call Command1_Click
End Sub
Private Sub irplaymusic_Click()
Call Command2_Click
End Sub
Private Sub ishowme_Click()
Me.Show
End Sub
Private Sub Timer1_Timer()
'用於進行動態狀態欄
If ier = True Then
Label1.Caption = " " & Label1.Caption
ier = False
ElseIf er = False Then
Label1.Caption = Right$(Label1.Caption, Len(Label1.Caption) - 3)
ier = True
End If
'用於判斷是否已經播放完成 播放完成就隨機播放一首
If WindowsMediaPlayer1.playState = 1 Then Call rPlayMusic
'也可以播放下一首 if WindowsMediaPlayer1.playstate=1 then call command3_click
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'氣泡單擊時的滑鼠事件
Dim cEvent As Single
cEvent = X / Screen.TwipsPerPixelX
Select Case cEvent
Case MouseMove
'Debug.Print "MouseMove"
Case LeftUp
' Debug.Print "左鍵放開"
Case LeftDown
' Debug.Print "左鍵按下"
Case LeftDbClick
' Debug.Print "左鍵雙擊"
Form1.WindowState = 0
Form1.Show
Case MiddleUp
' Debug.Print "中間鍵放開"
Case MiddleDown
' Debug.Print "中間鍵按下"
Case MiddleDbClick
' Debug.Print "中間鍵單擊"
Case RightUp
' Debug.Print "右健放開"
Case RightDown
' Debug.Print "右健按下"
Me.PopupMenu Me.Menu
Case RightDbClick
' Debug.Print "右健雙擊"
Case BalloonClick
' Debug.Print "單擊氣泡"'
End Select
End Sub ''
8. 用VB做個音樂播放器可以添加本地音樂的!可以的話!咋添加咋寫代碼急急急!
很簡單的
沒要求的話添加一個list wmp 和幾個按鈕就可以了
這樣一個簡單的音樂播放器就製作成功了,想要好看點的話可以用UI,列表插件等
9. VB 怎樣把歌曲放入WindowsMediaPlayer播放器插件中讓其播放
添加那個控制項。WindowsMediaPlayer1
然後
Me.WindowsMediaPlayer1.URL = "E:\My Music\今天 劉德華.mp3"
應該就OK了。
10. VB 做音樂播放器,播放列表怎麼弄
添加一個file ,按鈕,wmp控制項,timer(這能制動播放下一首)
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pIdl As Long, ByVal pszPath As String) As Long
Private Type BrowseInfo
hwndOwner As Long
piDLroot As Long
pszdisplayName As String
lpsztitle As String
ulFlags As Long
lpfncallback As Long
lParam As Long
iImage As Long
End Type
Private Sub Command1_Click()
Dim bi As BrowseInfo
Dim folderid As Long
Dim pb As String
With bi
.hwndOwner = Me.hWnd
.lpsztitle = "把輸出的文件存放到這個文件夾:"
.ulFlags = 3
End With
folderid = SHBrowseForFolder(bi)
If folderid = 0 Then Exit Sub
pb = String$(260, 0)
SHGetPathFromIDList folderid, pb
pb = Left$(pb, InStr(pb, vbNullChar) - 1)
File1.Path = pb
End Sub
Private Sub file1_Click()
WindowsMediaPlayer1.URL = File1.Path & "\" & File1.FileName
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
If WindowsMediaPlayer1.playState = 1 Then
WindowsMediaPlayer1.URL = File1.Path & "\" & File1.List(File1.ListIndex + 1)
If File1.ListCount > File1.ListIndex + 1 Then
File1.ListIndex = File1.ListIndex + 1
End If
End If
End Sub