diff --git a/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor b/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor
index 1ac1449..65bc7bd 100644
--- a/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor
+++ b/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor
@@ -6,6 +6,7 @@
@using HushianWebApp.Service
@using HushianWebApp.Services
@using Microsoft.AspNetCore.SignalR.Client;
+@using System.Threading;
@inject NavigationManager NavigationManager
@inject ChatService ChatService
@@ -77,11 +78,26 @@
- @if (msg.FileContent != null && msg.FileContent.Length > 0 && !string.IsNullOrWhiteSpace(msg.FileType) && msg.FileType.StartsWith("image/"))
+ @if (msg.FileContent != null && msg.FileContent.Length > 0 && !string.IsNullOrWhiteSpace(msg.FileType))
{
-
-
-
+ @if (msg.FileType.StartsWith("image/"))
+ {
+
+
+
+ }
+ else if (msg.FileType.StartsWith("audio/"))
+ {
+
+
+
+ @GetAudioDuration(msg.FileContent)
+
+
+ }
@if (!string.IsNullOrWhiteSpace(msg.text))
{
@msg.text
@@ -159,10 +175,31 @@
+
+
+
+
+
+
@if (SelectedImagePreview != null)
{
@@ -170,6 +207,33 @@
}
+
+
+ @if (RecordedAudioBytes != null)
+ {
+
+
+
+
+ @RecordedAudioDuration
+
+
+
+
+ }
+
+
+ @if (IsRecording)
+ {
+
+
+
+ در حال ضبط... @RecordingTime
+
+
+ }
}
@@ -214,6 +278,16 @@
IBrowserFile? SelectedImageFile = null;
byte[]? SelectedImageBytes = null;
string? SelectedImagePreview = null;
+
+ // Audio recording properties
+ bool IsRecording = false;
+ string RecordingTime = "00:00";
+ byte[]? RecordedAudioBytes = null;
+ string? RecordedAudioUrl = null;
+ string RecordedAudioDuration = "00:00";
+ private System.Threading.Timer? recordingTimer;
+ private DateTime recordingStartTime;
+
bool chatloading = false;
public bool IsLogin { get; set; } = false;
public bool IsEndFirstProcess { get; set; } = false;
@@ -243,16 +317,118 @@
return value;
}
}
+
+ // Audio recording methods
+ private async Task ToggleAudioRecording()
+ {
+ if (IsRecording)
+ {
+ await StopAudioRecording();
+ }
+ else
+ {
+ await StartAudioRecording();
+ }
+ }
+
+ private async Task StartAudioRecording()
+ {
+ try
+ {
+ var result = await JS.InvokeAsync