VB.net如何播放音乐 vbs播放音乐代码

VB.NET中播放背景音乐最简单的办法是什么啊?给你我的程序,自己研究一下吧,我也不是很明白 。
Public Class Form1
Private Declare Auto Function PlaySound Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer
Const SND_filename As Integer = H20000
Const SND_alias As Integer = H10000
Const SND_sync As Integer = H0
Declare Auto Function waveOutGetNumDevs Lib "winmm.dll" Alias "waveOutGetNumDevs" () As Integer
Declare Auto Function sndPlaySound Lib "winmm.dll" (ByVal filename As String, ByVal options As Integer) As Integer
Private Const SND_memory As Integer = H4
Private Const SND_async As Integer = H1
Private Const proess_domain As String = ""
Const SND_sync1 = H0
Const SND_async1 = H1
Const SND_nodefault = H2
Const SND_loop = H8
Const SND_nostop = H10
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Beep()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim strFileName As String = "start.wav"
PlaySound(strFileName, 0, SND_filename)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
PlaySound("systemstart", 0, SND_alias Or SND_sync)
End Sub
【VB.net如何播放音乐 vbs播放音乐代码】Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim ret As Long
Dim strfilename As String
strfilename = "start.wav"
ret = sndPlaySound(strfilename.ToCharArray, 0)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim i As Integer
i = waveOutGetNumDevs()
If i0 Then
MsgBox("可以播放声音", 64, "检测")
Else
MsgBox("不能播放声音", 64, "检测")
End If
End Sub
End Class
vb.net怎么播放音乐文件添加一个 WindowsMediaPlayer 控件 一句代码即可播放音乐 AxWindowsMediaPlayer1.URL = "音乐地址"
vb.net 中 如何实现 播放mp3文件在.NET里,没有托管的音乐播放器,用API只能播放WAV格式,对于MP3等形式的音频文件,就要依赖于其他控件了,常用的就是
MediaPlayer 。使用方法:
在工具箱上点右键,选择“选择项目(Choose Items)”,切到COM选项卡,找到 Windows Media Player,勾?。范?
在t工具箱上,把刚才加入的MediaPlayer控件,拖放到窗体上
代码:
WindowsMediaPlayer1.URL = "mp3文件路径,支持网络路径"
WindowsMediaPlayer1.Ctlcontrols.play
基本就OK了,至于其他的操作诸如下一曲上一曲暂停停止 , 直接看 WindowsMediaPlayer1.Ctlcontrols. 里面的方法吧 。
VB.net里面怎么添加音乐给你个 很简单的
Public Class Form1
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
‘声明函数mciexcute加入库winmm.all
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call mciExecute("play E:\music\music\单身情歌.wma ")
'在 formload过程中调用函数mciexcute里面 是文件 路径
End Sub
End Class
VB.net如何加载音效?方法一:调用系统DLL(这个有点不完善,也就是播放声音时窗体无法控制,效果相当于Enabled=true , 但音频播放完毕后就没事了)
Private Declare Function sndPlaySound Lib "Winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

推荐阅读