Click to See Complete Forum and Search --> : How to play music in a vb.net application?


ZhiYi
April 23rd, 2006, 08:33 PM
Hi,

How to we play music files (e.g .wma or .mp3 etc) in a vb.net application when the application is running?

And how to let a few songs play one after the other? i.e when the first song finishes, the second one starts after a short pause.

aniskhan
April 24th, 2006, 12:27 AM
u can start a new process
Dim MyProcess As New Process
MyProcess.StartInfo.FileName = "C:\MySong.mp3"
MyProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
MyProcess.Start()
u can also use API

Private Sub playWave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles playWave.Click

Const SND_FILENAME As Integer = &H20000

PlaySound(fileName, 0, SND_FILENAME)
End Sub

Private Declare Auto Function PlaySound Lib "winmm.dll" (ByVal
lpszSoundName As _
String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer

in VB2005My.Computer.Audio.Play(fileName, AudioPlayMode.Background)

aniskhan
April 24th, 2006, 01:27 AM
My.Computer.Audio only supports WAV format
u can also use the windows mediaplayer control.

HanneSThEGreaT
April 24th, 2006, 02:18 AM
I usually recommend downloading the Media Player SDK, which includes, all files needed in order to use the Media Player productively. You have access to all Media Player functionalities. Also included are VB.NET, C#, VB6 (I think) and VC++ 6 samples.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/windowsmediaplayer10sdk.asp

ZhiYi
April 24th, 2006, 10:43 AM
Hi all,

thanks for the replies! :D

I tried the process creation method. It can play the music but when the program is run , the windows media player runs also!

How to make the music to run in the background without the win media player appearing?

HanneSThEGreaT
April 24th, 2006, 01:33 PM
Have you tried implementing the API, as suggested by aniskhan ¿

ZhiYi
April 26th, 2006, 09:54 PM
Havent because I do not know about using APIs yet.

Now,I am trying out the Windows Media SDK