Neyja
New member
- Joined
- Feb 3, 2014
- Messages
- 4
- Programming Experience
- Beginner
Hello all,
I use "mciSendString" function to play audio file , it works great in a button
But i need to use it in a thread like this:
My problem is that it doesnt work in a thread , so if someone can explain me how to use it in a thread, it iwll be great.
Thank you.
I use "mciSendString" function to play audio file , it works great in a button
VB.NET:
Public Class Form1
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
play()
End Sub
Sub play()
Dim musicAlias As String = "myAudio"
Dim musicPath As String = "Call.mp3"
mciSendString("Open " & Chr(34) & musicPath & Chr(34) & " alias " & musicAlias, CStr(0), 0, 0)
mciSendString("play " & musicAlias, CStr(0), 0, 0)
End Sub
End Class
But i need to use it in a thread like this:
VB.NET:
Public Class Form1
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim essai As New Threading.Thread(AddressOf play)
essai.IsBackground = True
essai.Start()
End Sub
Sub play()
Dim musicAlias As String = "myAudio"
Dim musicPath As String = "Call.mp3"
mciSendString("Open " & Chr(34) & musicPath & Chr(34) & " alias " & musicAlias, CStr(0), 0, 0)
mciSendString("play " & musicAlias, CStr(0), 0, 0)
End Sub
End Class
My problem is that it doesnt work in a thread , so if someone can explain me how to use it in a thread, it iwll be great.
Thank you.