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