资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net播放器按钮,vb音乐播放控件

如何在VB.NET中调用MP3播放器

工具栏里选择"添加,删除组件"

创新互联公司专注于福鼎网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供福鼎营销型网站建设,福鼎网站制作、福鼎网页设计、福鼎网站官网定制、微信小程序开发服务,打造福鼎网络公司原创品牌,更为您提供福鼎网站排名全网营销落地服务。

选择com组件

选择"Windows Media Player "

然后在界面上加入这个组件

代码

Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) _

Handles Button1.Click

Const DATA_FILE_EXTENSION As String = ".mp3"

Dim dlgFileDialog As New OpenFileDialog

With dlgFileDialog

.Filter = DATA_FILE_EXTENSION _

" files (*" DATA_FILE_EXTENSION "|*" DATA_FILE_EXTENSION

.FilterIndex = 1

.RestoreDirectory = True

If .ShowDialog() = DialogResult.OK Then

'Play the sound file

Me.AxWindowsMediaPlayer1.URL = dlgFileDialog.FileName

End If

End With

End Sub

参考资料中可以看到很详细的步骤

vb.net内嵌的视频怎么用media player控件播放啊?

“工具箱”中单击右键,选择“选择项”菜单,打开“选择工具箱项”窗口,选择“COM组件”标签,在列表中找到并勾选“Windows Media Player”组件,单击“确定”按钮。将该组件添加到指定的工具箱选项卡中,然后在工具箱里面找 Windows Media Player 控件,拉到form里面,拉出来的控件就是AxWindowsMediaPlayer

用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

VB.net如何实现点击按钮两种图标进行互换,就像播放器开始暂停一样?

'在窗体上添加一个按钮测试

Private

m_PlayFlag

As

Boolean

=

False

'是否正在播放

Private

Sub

Button1_Click(ByVal

sender

As

System.Object,

ByVal

e

As

System.EventArgs)

Handles

Button1.Click

If

m_PlayFlag

=

False

Then

Button1.Image

=

Image.FromFile("d:\play.jpg")

'更换为播放图标

m_PlayFlag

=

True

'改变标志

Else

Button1.Image

=

Image.FromFile("d:\pause.jpg")

'更换为暂停图标

m_PlayFlag

=

False

'改变标志

End

If

End

Sub

Private

Sub

Form1_Load(ByVal

sender

As

System.Object,

ByVal

e

As

System.EventArgs)

Handles

MyBase.Load

'窗体加载时使用暂停图标

Button1.Image

=

Image.FromFile("d:\pause.jpg")

End

Sub

vb.net中如何播放声音,是要什么控件嘛?

My.Computer.Audio.Play("SoundFile.wav")

SoundFile.wav是你要播放的声音文件的路径


本文名称:vb.net播放器按钮,vb音乐播放控件
当前网址:http://cdkjz.cn/article/hseoos.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220