tipt
asked on
Play a mp3 file as bgsound in winform ?
User can select a mp3 file they want (i used OpenFileDialog to open it). and this file will be a bgsound of this winform. How can i do it ?
It's urgent. TIA
It's urgent. TIA
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i can't understand. Please explain it clearly ?
tipt:
Add the above code to your program,
then once you have found the path to the file to play using opendialog,
Call the PlaySound Sub, passing the file name as its parameter
Dabas
Add the above code to your program,
then once you have found the path to the file to play using opendialog,
Call the PlaySound Sub, passing the file name as its parameter
Dabas
Good day Dabas
i took a form and put a button on it, and then pasted this
code into it.
i just get 2 beeps.
when i console.writeline(path) in the playsound sub, the
path shows correctly.
there are no other files playing at the time.
this is prob the nearest i got to playing a mp3 though
Private Declare Function PlaySoundAPI Lib "winmm.dll"
Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule
As Long, ByVal dwFlags As Long) As Long
Public Const SND_NOSTOP As Integer = &H10 ' don't stop
any currently playing sound
Public Sub PlaySound(ByVal Path As String)
If PlaySoundAPI(Path, 0, SND_NOSTOP) = 0 Then
Beep()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim playstring As String = "C:\1.mp3"
PlaySoundAPI(playstring, 0, SND_NOSTOP)
PlaySound(playstring)
End Sub
jxharding,
You are right. PLAYSoundAPI seems to be geared to wav files, not mp3 ones.
This PAQ might point to the right direction:
https://www.experts-exchange.com/questions/20929854/Background-music-in-vb-net.html#10675256 "Background music in vb .net"
Dabas
You are right. PLAYSoundAPI seems to be geared to wav files, not mp3 ones.
This PAQ might point to the right direction:
https://www.experts-exchange.com/questions/20929854/Background-music-in-vb-net.html#10675256 "Background music in vb .net"
Dabas
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dabas