initial commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
Imports System.Threading
|
||||
Public Class VoiceChat
|
||||
|
||||
Public C As Client
|
||||
Public MICR As Boolean
|
||||
Public sourcestream As NAudio.Wave.WaveInEvent = Nothing
|
||||
|
||||
Public Function VoiceStop()
|
||||
Try
|
||||
MICR = False
|
||||
If sourcestream IsNot Nothing Then
|
||||
sourcestream.StopRecording()
|
||||
sourcestream.Dispose()
|
||||
sourcestream = Nothing
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Debug.WriteLine(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
Public Sub audioDataAvailable(ByVal sender As Object, ByVal e As NAudio.Wave.WaveInEventArgs)
|
||||
Try
|
||||
If MICR = True Then
|
||||
Dim B As Byte() = SB("VOICEWAV" & SettingsHelper.SPL & Convert.ToBase64String(Compress(e.Buffer)) & SettingsHelper.SPL & e.BytesRecorded & SettingsHelper.SPL)
|
||||
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
||||
ToolStripStatusLabel1.Text = "Size : " & " [" & BytesToString(B.LongLength) & "]"
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Debug.WriteLine(ex.Message)
|
||||
End Try
|
||||
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 VoiceChat_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||||
Dim B As Byte() = SB("ENDVOICE")
|
||||
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
||||
VoiceStop()
|
||||
End Sub
|
||||
|
||||
Private Sub Guna2GradientButton1_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton1.Click
|
||||
Try
|
||||
If Guna2GradientButton1.Text = "Start" Then
|
||||
|
||||
sourcestream = New NAudio.Wave.WaveInEvent()
|
||||
sourcestream.DeviceNumber = Convert.ToInt32(Guna2ComboBox1.SelectedIndex)
|
||||
sourcestream.NumberOfBuffers = 1
|
||||
sourcestream.BufferMilliseconds = 500
|
||||
sourcestream.NumberOfBuffers = 5
|
||||
sourcestream.WaveFormat = New NAudio.Wave.WaveFormat(8000, 16, 1)
|
||||
AddHandler sourcestream.DataAvailable, New EventHandler(Of NAudio.Wave.WaveInEventArgs)(AddressOf audioDataAvailable)
|
||||
sourcestream.StartRecording()
|
||||
MICR = True
|
||||
|
||||
Guna2GradientButton1.Text = "Stop"
|
||||
Guna2GradientButton1.Image = My.Resources._Stop
|
||||
PictureBox1.Enabled = True
|
||||
|
||||
Else
|
||||
|
||||
VoiceStop()
|
||||
Guna2GradientButton1.Text = "Start"
|
||||
Guna2GradientButton1.Image = My.Resources.Play
|
||||
PictureBox1.Enabled = False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MessageBox.Show(ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Guna2ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Guna2ComboBox1.SelectedIndexChanged
|
||||
VoiceStop()
|
||||
Guna2GradientButton1.Text = "Start"
|
||||
Guna2GradientButton1.Image = My.Resources.Play
|
||||
PictureBox1.Enabled = False
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user