vbnet多媒体播放器 vb音乐播放器
用VB.NET 做个多媒体播放器啊!~能播放ATI格式的文件能看MTV就行了
方法只是添加一个播放器控件,再改它的属性就可以了.
创新互联是专业的宜川网站建设公司,宜川接单;提供做网站、成都做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行宜川网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
添加播放器控件的方法:在窗体设计模式中,右键单击”工具箱”->”WINDOWS 窗体”,选择”添加/移除项”,再选择”COM组件”标签找到”WINDOWS MEDIA PLAYER”项,选上.最后把添加了控件放到窗体中就行了.
我没有ATI格式的文件也不知道MEDIA PLAYER能放不,不行的话用别的控件试试,比如REALPLAYER.
邮件我已经发过去了.
关于多媒体播放器的播放菜单(vb.net 2005)
1.你使用的媒体控制是什么?
2.要加入ListBox的双击事件
3. 你这里只是用浏览对话框找到了mp3文件,并显示在列表框里。没有播放的代码。
张志晨
add
...............................................
添加WMplayer控件
Public Class Form1
Private Sub 打开目录ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 打开目录ToolStripMenuItem.Click
If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim f As IO.FileInfo
Dim d As IO.DirectoryInfo = New IO.DirectoryInfo(FolderBrowserDialog1.SelectedPath)
Dim file As String
For Each f In d.GetFiles("*.mp3")
file = (f.FullName)
ListBox1.Items.Add(file)
Next
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged‘双击就播放
AxWindowsMediaPlayer1.URL = ListBox1.Items(ListBox1.SelectedIndex)
End Sub
End Class
用VB.NET编多媒体播放器
我这里有一段前段时间写的测试代码,使用WMPLib类,中间有你需要的功能,你可以参考下:
使用wmp.currentMedia.duration和wmp.currentMedia.durationString分别以double和string获得当前媒体的播放时间,使用wmp.settings.volume设置音量大小,使用wmp.controls.currentPosition设置当前播放时间点
Imports WMPLib
Public Class FrmMain
Dim WithEvents wmp As WMPLib.WindowsMediaPlayer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wmp = New WMPLib.WindowsMediaPlayer()
TextBox1.Text = TextBox1.Text vbCrLf "当前播放状态:" wmp.status
wmp.uiMode = "Mini"
wmp.settings.balance = 1
wmp.enableContextMenu = True
wmp.fullScreen = False
wmp.windowlessVideo = True
wmp.enabled = True
Dim wmpMediaList As IWMPPlaylist = wmp.newPlaylist("默认播放列表", "")
Dim wmpMedia As IWMPMedia = wmp.newMedia(My.Computer.FileSystem.CurrentDirectory "\Human.mp3")
With wmpMediaList
.appendItem(wmpMedia)
End With
'wmp.URL = "\\192.168.1.247\sharoncn\music\Human.mp3"
wmp.currentMedia = wmpMedia
wmp.settings.autoStart = True
tBarPlay.Value = 0
ListBox1.Items.Add(wmpMediaList.name)
ListBox1.SelectedIndex = 0
ListBox2.Items.Add(wmpMediaList.Item(0).name)
ListBox2.SelectedIndex = 0
tbar.Maximum = 100
tbar.Value = 50
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Sub wmp_PlayStateChange(ByVal NewState As Integer) Handles wmp.PlayStateChange
tBarPlay.Maximum = wmp.currentMedia.duration * 10
Label1.Text = "总时间:" wmp.currentMedia.durationString
TextBox1.Text = TextBox1.Text vbCrLf "当前播放状态:" NewState
If NewState = 1 Then
wmp.controls.play()
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.SelectionStart = Len(TextBox1.Text)
TextBox1.ScrollToCaret()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label2.Text = "当前播放进度:" wmp.controls.currentPositionString
tBarPlay.Value = CInt(wmp.controls.currentPosition * 10)
End Sub
Private Sub tbar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbar.Scroll
wmp.settings.volume = tbar.Value
End Sub
Private Sub tBarPlay_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tBarPlay.Scroll
wmp.controls.currentPosition = tBarPlay.Value / 10
End Sub
End Class
网站栏目:vbnet多媒体播放器 vb音乐播放器
链接地址:http://azwzsj.com/article/dodpjsj.html