Преглед изворни кода

host: read bit rate; UI: show bit rate in FileIcon

HOME пре 2 година
родитељ
комит
15992a1896

+ 1 - 8
FNZCM/FNZCM.BlazorWasm/Helpers/FnzDataSetHelper.cs

@@ -3,8 +3,6 @@ using FNZCM.BlazorWasm.UI.Components;
 using FNZCM.BlazorWasm.Utility;
 using FNZCM.Shared.Helpers;
 using FNZCM.Shared.MediaModels;
-using Newtonsoft.Json;
-using System.Text;
 
 namespace FNZCM.BlazorWasm.Helpers
 {
@@ -230,14 +228,9 @@ namespace FNZCM.BlazorWasm.Helpers
                 Length = mediaTag.Length,
                 Bit = mediaTag.Bit,
                 Freq = mediaTag.Freq,
+                BitRate = mediaTag.BitRate,
             };
 
-            var lst = new List<string>();
-            if (m.Bit != 0) lst.Add($"{m.Bit}b");
-            if (m.Freq != 0) lst.Add($"{m.Freq / 100f}");
-
-            m.ParamDesc = string.Join("", lst);
-
             return m;
         }
     }

+ 1 - 2
FNZCM/FNZCM.BlazorWasm/Models/FeMediaTag.cs

@@ -12,7 +12,6 @@
 
         public int Bit { get; set; }
         public int Freq { get; set; }
-
-        public string ParamDesc { get; set; }
+        public int BitRate { get; set; }
     }
 }

+ 27 - 3
FNZCM/FNZCM.BlazorWasm/UI/Components/FileIcon.razor

@@ -3,10 +3,10 @@
     [Parameter] public bool ShowParam { get; set; }
 }
 
-
 @if (Track != null)
 {
     var ex = Path.GetExtension(Track.Path?.ToLower());
+
     <span class="badge bg-secondary">
         @switch (ex)
         {
@@ -31,9 +31,33 @@
                 break;
         }
         @ex.Substring(1).ToUpper()
-        @if (ShowParam && Track.Tag?.ParamDesc != null)
+
+        @if (ShowParam && Track.Tag?.Bit > 0)
         {
-            <br>@Track.Tag.ParamDesc
+            <span class="border-start ms-1 ps-1">@(Track.Tag.Bit)</span>
         }
     </span>
+
+    @if (ShowParam && (Track.Tag?.BitRate > 0 || Track.Tag?.Freq > 0))
+    {
+         <span class="badge bg-secondary">
+            @if (Track.Tag?.BitRate > 0)
+            {
+                @if (Track.Tag.BitRate < 1000)
+                {
+                    <span>@(Track.Tag.BitRate)k</span>
+                }
+                else
+                {
+                    <span>@($"{Track.Tag.BitRate / 1000f:N2}")m </span>
+                }
+            }
+
+
+            @if (Track.Tag?.Freq > 0)
+            {
+                <span class="ms-1">@(Track.Tag.Freq / 100f)</span>
+            }
+        </span>
+    }
 }

+ 2 - 2
FNZCM/FNZCM.BlazorWasm/UI/Views/Default/Playlist/PlaylistTableItem.razor

@@ -17,7 +17,7 @@
                 var arr = PlaylistHelper[Playlist.Value.Key];
 
                 <tr class="table-primary">
-                    <td class="w-0" style="width:0" @onclick="()=>{IsExpand=!IsExpand;}">
+                    <td style="width:0" @onclick="()=>{IsExpand=!IsExpand;}">
                         <button type="button" class="btn btn-primary p-2">
                             @if (IsExpand)
                             {
@@ -67,7 +67,7 @@
                                     <td colspan="2" style="width:0">
                                         <img src="@track.Disc.CoverPath" style="height:50px" />
                                     </td>
-                                    <td class="align-middle">
+                                    <td class="align-middle" style="width:250px">
                                         <FileIcon Track="@track" ShowParam="true"></FileIcon>
                                     </td>
                                     <td class="align-middle w-100">

+ 1 - 19
FNZCM/FNZCM.ConHost/FNZCM.ConHost.csproj

@@ -2,10 +2,9 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>net6.0</TargetFramework>
+    <TargetFramework>net7.0</TargetFramework>
   </PropertyGroup>
 
-
   <ItemGroup>
     <PackageReference Include="K4os.Compression.LZ4" Version="1.2.16" />
     <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
@@ -18,21 +17,4 @@
     <ProjectReference Include="..\FNZCM.Shared\FNZCM.Shared.csproj" />
   </ItemGroup>
 
-  <ItemGroup>
-    <Compile Update="Resource.Designer.cs">
-      <DesignTime>True</DesignTime>
-      <AutoGen>True</AutoGen>
-      <DependentUpon>Resource.resx</DependentUpon>
-    </Compile>
-  </ItemGroup>
-
-  <ItemGroup>
-    <EmbeddedResource Update="Resource.resx">
-      <Generator>ResXFileCodeGenerator</Generator>
-      <LastGenOutput>Resource.Designer.cs</LastGenOutput>
-    </EmbeddedResource>
-  </ItemGroup>
-
-  <ProjectExtensions><VisualStudio><UserProperties config_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
-
 </Project>

+ 3 - 2
FNZCM/FNZCM.ConHost/HostProgram.cs

@@ -1259,11 +1259,12 @@ namespace FNZCM.ConHost
                     (int)tagLib.Tag.Disc,
                     (int)tagLib.Tag.Track,
                     tagLib.Tag.Title,
-                    string.Join(";", tagLib.Tag.Performers??new string[0]),
+                    string.Join(";", tagLib.Tag.Performers ?? new string[0]),
                     tagLib.Properties?.BitsPerSample ?? 0,
                     tagLib.Properties?.AudioSampleRate ?? 0,
                     (int)(tagLib.Properties?.Duration.TotalSeconds ?? 0),
-                    fi.Length
+                    fi.Length,
+                    tagLib.Properties?.AudioBitrate ?? 0
                 );
             }
             catch (Exception e)

+ 1 - 1
FNZCM/FNZCM.Shared/FNZCM.Shared.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>net6.0</TargetFramework>
+    <TargetFramework>net7.0</TargetFramework>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
   </PropertyGroup>

+ 3 - 1
FNZCM/FNZCM.Shared/MediaModels/MediaTag.cs

@@ -2,7 +2,7 @@
 {
     public class MediaTag
     {
-        public MediaTag(string album,int discNum,int trackNum, string title, string artist,int bit,int freq, int duration, long length)
+        public MediaTag(string album,int discNum,int trackNum, string title, string artist,int bit,int freq, int duration, long length,int bitRate)
         {
             Album = album;
             DiscNum = discNum;
@@ -10,6 +10,7 @@
             Title = title;
             Duration = duration;
             Length = length;
+            BitRate = bitRate;
             Artist = artist;
             Bit = bit;
             Freq = freq;
@@ -24,5 +25,6 @@
         public int Freq { get; }
         public int Duration { get; }
         public long Length { get; }
+        public int BitRate { get; }
     }
 }