diff --git a/RadioDJViewer/Main.Designer.cs b/RadioDJViewer/Main.Designer.cs
index 050557b..8912054 100644
--- a/RadioDJViewer/Main.Designer.cs
+++ b/RadioDJViewer/Main.Designer.cs
@@ -86,9 +86,12 @@
//
// toolStripStatusLabel2
//
- this.toolStripStatusLabel2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripStatusLabel2.Image")));
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(16, 20);
+ // Use BackColor only to indicate status. Text is a single space so the label renders as a square.
+ this.toolStripStatusLabel2.Text = " ";
+ this.toolStripStatusLabel2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
+ this.toolStripStatusLabel2.BackColor = System.Drawing.Color.Red;
//
// toolStripStatusLabel4
//
diff --git a/RadioDJViewer/Main.cs b/RadioDJViewer/Main.cs
index 068dfdf..50428e3 100644
--- a/RadioDJViewer/Main.cs
+++ b/RadioDJViewer/Main.cs
@@ -517,6 +517,49 @@ namespace RadioDJViewer
File.WriteAllText(Path.Combine(outputFolderPath, "album.txt"), marqueeTextAlbum);
}
+ // Update in-memory cache for widget server
+ try
+ {
+ WidgetServer.CachedArtist = marqueeTextArtist ?? string.Empty;
+ WidgetServer.CachedTitle = marqueeTextTitle ?? string.Empty;
+ byte[] imgBytes = null;
+ // Prefer album art from main images folder
+ if (!string.IsNullOrEmpty(albumArt) && !string.IsNullOrEmpty(mainImagesFolderPath))
+ {
+ var imagePath = Path.Combine(mainImagesFolderPath, albumArt);
+ if (File.Exists(imagePath))
+ {
+ try
+ {
+ using (var img = System.Drawing.Image.FromFile(imagePath))
+ {
+ using (var ms = new MemoryStream())
+ {
+ img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+ imgBytes = ms.ToArray();
+ }
+ }
+ }
+ catch { imgBytes = null; }
+ }
+ }
+ // Fallback to embedded resource image
+ if (imgBytes == null)
+ {
+ var fallback = Properties.Resources.fallback;
+ if (fallback != null)
+ {
+ using (var ms = new MemoryStream())
+ {
+ fallback.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+ imgBytes = ms.ToArray();
+ }
+ }
+ }
+ WidgetServer.CachedImageBytes = imgBytes;
+ }
+ catch { }
+
// Handle album art image
if (!string.IsNullOrWhiteSpace(albumArt))
{
diff --git a/RadioDJViewer/Properties/AssemblyInfo.cs b/RadioDJViewer/Properties/AssemblyInfo.cs
index cb97412..ef23503 100644
--- a/RadioDJViewer/Properties/AssemblyInfo.cs
+++ b/RadioDJViewer/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("1.8.0")]
-[assembly: AssemblyFileVersion("1.8.0")]
+[assembly: AssemblyVersion("1.9.0")]
+[assembly: AssemblyFileVersion("1.9.0")]
diff --git a/RadioDJViewer/RadioDJViewer.csproj b/RadioDJViewer/RadioDJViewer.csproj
index 051525c..88d3f87 100644
--- a/RadioDJViewer/RadioDJViewer.csproj
+++ b/RadioDJViewer/RadioDJViewer.csproj
@@ -13,6 +13,7 @@
true
true
icon.ico
+ false
publish\
true
Disk
@@ -25,7 +26,6 @@
true
0
1.0.0.%2a
- false
false
true
diff --git a/RadioDJViewer/WidgetServer.cs b/RadioDJViewer/WidgetServer.cs
index 0b5e316..7667b57 100644
--- a/RadioDJViewer/WidgetServer.cs
+++ b/RadioDJViewer/WidgetServer.cs
@@ -18,6 +18,11 @@ namespace RadioDJViewer
///
public class WidgetServer
{
+ // In-memory cache for fast serving
+ public static string CachedArtist = "";
+ public static string CachedTitle = "";
+ public static byte[] CachedImageBytes = null;
+
private readonly int port;
private readonly Func getArtist;
private readonly Func getTitle;
@@ -105,13 +110,28 @@ namespace RadioDJViewer
if (path == "/" || path.Equals("/index.html", StringComparison.OrdinalIgnoreCase))
{
var html = htmlTemplate ?? "";
- html = html.Replace("{{ARTIST}}", WebUtility.HtmlEncode(getArtist()))
- .Replace("{{TITLE}}", WebUtility.HtmlEncode(getTitle()));
+ // Replace placeholders with in-memory cache values
+ html = html.Replace("{{ARTIST}}", WebUtility.HtmlEncode(CachedArtist ?? string.Empty))
+ .Replace("{{TITLE}}", WebUtility.HtmlEncode(CachedTitle ?? string.Empty));
var buf = Encoding.UTF8.GetBytes(html);
resp.ContentType = "text/html; charset=utf-8";
resp.ContentLength64 = buf.Length;
resp.OutputStream.Write(buf, 0, buf.Length);
}
+ else if (path.Equals("/artist.txt", StringComparison.OrdinalIgnoreCase))
+ {
+ var buf = Encoding.UTF8.GetBytes(CachedArtist ?? string.Empty);
+ resp.ContentType = "text/plain; charset=utf-8";
+ resp.ContentLength64 = buf.Length;
+ resp.OutputStream.Write(buf, 0, buf.Length);
+ }
+ else if (path.Equals("/title.txt", StringComparison.OrdinalIgnoreCase))
+ {
+ var buf = Encoding.UTF8.GetBytes(CachedTitle ?? string.Empty);
+ resp.ContentType = "text/plain; charset=utf-8";
+ resp.ContentLength64 = buf.Length;
+ resp.OutputStream.Write(buf, 0, buf.Length);
+ }
else if (path.Equals("/style.css", StringComparison.OrdinalIgnoreCase))
{
var buf = Encoding.UTF8.GetBytes(cssText ?? "");
@@ -126,17 +146,15 @@ namespace RadioDJViewer
resp.ContentLength64 = buf.Length;
resp.OutputStream.Write(buf, 0, buf.Length);
}
- else if (path.Equals("/albumart", StringComparison.OrdinalIgnoreCase))
+ else if (path.Equals("/Album-Art.png", StringComparison.OrdinalIgnoreCase) || path.Equals("/album-art.png", StringComparison.OrdinalIgnoreCase))
{
- var imagePath = getAlbumArtPath();
- if (!string.IsNullOrEmpty(imagePath) && File.Exists(imagePath))
+ if (CachedImageBytes != null && CachedImageBytes.Length > 0)
{
try
{
- byte[] imgBytes = File.ReadAllBytes(imagePath);
- resp.ContentType = GetMimeTypeFromPath(imagePath);
- resp.ContentLength64 = imgBytes.Length;
- resp.OutputStream.Write(imgBytes, 0, imgBytes.Length);
+ resp.ContentType = "image/png";
+ resp.ContentLength64 = CachedImageBytes.Length;
+ resp.OutputStream.Write(CachedImageBytes, 0, CachedImageBytes.Length);
}
catch
{