vb.net媒体流回放 net 流媒体
用VB.NET编多媒体播放器
我这里有一段前段时间写的测试代码,使用WMPLib类,中间有你需要的功能,你可以参考下:
创新互联专注于企业成都全网营销推广、网站重做改版、驿城网站定制设计、自适应品牌网站建设、H5开发、购物商城网站建设、集团公司官网建设、成都外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为驿城等各大城市提供网站开发制作服务。
使用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
VB中RM控件的应用问题:流媒体如何播放
控件使用是小问题,问题是你有没有流媒体的通讯传输设备,有就可以了!设备传文件过来的的时候就像使用一般多媒体文件一样,找到它就可以了!关键是流媒体转换设备啊!
关于多媒体播放器的播放菜单(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 做个多媒体播放器啊!~能播放ATI格式的文件能看MTV就行了
方法只是添加一个播放器控件,再改它的属性就可以了.
添加播放器控件的方法:在窗体设计模式中,右键单击”工具箱”->”WINDOWS 窗体”,选择”添加/移除项”,再选择”COM组件”标签找到”WINDOWS MEDIA PLAYER”项,选上.最后把添加了控件放到窗体中就行了.
我没有ATI格式的文件也不知道MEDIA PLAYER能放不,不行的话用别的控件试试,比如REALPLAYER.
邮件我已经发过去了.
本文名称:vb.net媒体流回放 net 流媒体
标题链接:http://ybzwz.com/article/dosidog.html