Skip to content

Commit 5411b4e

Browse files
authored
Merge pull request #3 from Soapwood/design/HoverHighlighting
[Bug] Fix Overlay not having the scope to test ShazamAPI anymore.
2 parents 9e89fa1 + f897ab3 commit 5411b4e

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed

VXMusic/Notifications/SteamVR/SteamVRNotificationClient.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class SteamVRNotificationClient : Application, INotificationClient
1818

1919
private readonly SteamVRNotificationOverlay _steamVrNotificationClient;
2020

21-
private static string DefaultVxLogo;
21+
public static string DefaultVxLogo;
2222

2323
public SteamVRNotificationClient(IServiceProvider serviceProvider)
2424
: base(ApplicationType.Overlay)
@@ -72,7 +72,17 @@ public void SendNotificationInternal(string title, string content, int timeout,
7272
{
7373
_logger.LogTrace("Sending notification request to SteamVR.");
7474

75-
var imageBytes = Convert.FromBase64String(image);
75+
byte[] imageBytes;
76+
77+
try
78+
{
79+
imageBytes = Convert.FromBase64String(image);
80+
}
81+
catch (Exception ex)
82+
{
83+
_logger.LogInformation("Image returned from Shazam could not be parsed by the SteamVRNotificationClient. Falling back to the Default.");
84+
imageBytes = Convert.FromBase64String(SteamVRNotificationClient.DefaultVxLogo);
85+
}
7686

7787
Bitmap bitmap = new Bitmap(new MemoryStream(imageBytes));
7888

VXMusicDesktop/MVVM/ViewModel/HomeViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public HomeViewModel(SharedViewModel sharedViewModel)
2121
SharedViewModel = sharedViewModel;
2222
GetVxTipsText();
2323
FetchVxNewsText();
24+
25+
SharedViewModel.IsShazamApiConnected = true;
2426
}
2527

2628
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)

VXMusicDesktop/MVVM/ViewModel/MainViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public MainViewModel()
5959
CurrentView = HomeVM;
6060

6161
VXMusicOverlayInterface.SharedViewModel = SharedVM;
62+
VXMusicSession.SharedViewModel = SharedVM;
6263

6364
HomeViewCommand = new RelayCommand(o =>
6465
{

VXMusicDesktop/Overlay/VXMusicOverlayInterface.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ private static bool IsCurrentRecognitionClientConnected(RecognitionApi currentRe
425425
{
426426
case RecognitionApi.Shazam:
427427
return SharedViewModel.IsShazamApiConnected;
428-
case RecognitionApi.AudD:
429-
return SharedViewModel.IsAudDApiConnected;
430428
case RecognitionApi.Unknown:
431429
return false;
432430
default:
@@ -438,17 +436,18 @@ public static async Task<bool> HandleRecognitionRequest()
438436
{
439437
RecognitionApi currentRecognitionApi = App.VXMusicSession.RecognitionSettings.CurrentRecognitionApi;
440438

441-
if (!IsCurrentRecognitionClientConnected(currentRecognitionApi))
442-
{
443-
Logger.LogError($"Recognition Failed. {currentRecognitionApi} is not connected.");
444-
SharedViewModel.IsRecognitionRunning = false;
445-
//App.ToastNotification.Error($"{currentRecognitionApi} is not connected! Check your Recognition settings.");
446-
VXMusicSession.NotificationClient.SendNotification(NotificationLevel.Error, "Recognition Failed", $"{currentRecognitionApi} is not connected! Check your Recognition settings.", 8);
447-
App.VXMusicSession.ToastNotification.SendNotification(NotificationLevel.Error, "Recognition Failed", $"{currentRecognitionApi} is not connected! Check your Recognition settings.", 8);
448-
// Finish, or effectively cancel recognition if fails.
449-
SendMessageToVxMusicOverlayOverTcp(VXMMessage.RECOGNITION_FINISH);
450-
return false;
451-
}
439+
// This shouldn't be checked by the overlay anyway
440+
// if (!IsCurrentRecognitionClientConnected(currentRecognitionApi))
441+
// {
442+
// Logger.LogError($"Recognition Failed. {currentRecognitionApi} is not connected.");
443+
// SharedViewModel.IsRecognitionRunning = false;
444+
// //App.ToastNotification.Error($"{currentRecognitionApi} is not connected! Check your Recognition settings.");
445+
// VXMusicSession.NotificationClient.SendNotification(NotificationLevel.Error, "Recognition Failed", $"{currentRecognitionApi} is not connected! Check your Recognition settings.", 8);
446+
// App.VXMusicSession.ToastNotification.SendNotification(NotificationLevel.Error, "Recognition Failed", $"{currentRecognitionApi} is not connected! Check your Recognition settings.", 8);
447+
// // Finish, or effectively cancel recognition if fails.
448+
// SendMessageToVxMusicOverlayOverTcp(VXMMessage.RECOGNITION_FINISH);
449+
// return false;
450+
// }
452451

453452
if (!SharedViewModel.IsRecognitionRunning)
454453
{

VXMusicDesktop/VXMusicSession.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using VXMusic.Tidal.Authentication;
1717
using VXMusic.VRChat;
1818
using VXMusicDesktop.Core;
19+
using VXMusicDesktop.MVVM.ViewModel;
1920
using VXMusicDesktop.Theme;
2021
using VXMusicDesktop.Toast;
2122
using VXMusicDesktop.Update;
@@ -52,6 +53,8 @@ public class VXMusicSession
5253
public VXMusicSettingsSyncHandler VXMusicSettingsSync;
5354
public RegistryInterface RegistryInterface;
5455

56+
public static SharedViewModel SharedViewModel { get; set; }
57+
5558
public static event EventHandler LastFmLogin;
5659
//public static event EventHandler SpotifyLogin;
5760

@@ -75,8 +78,7 @@ public void Initialise()
7578
//NotificationClient = new XSOverlay(); //VXMusicAPI.SetNotificationClient(notificationSettings.CurrentNotificationService);
7679

7780
NotificationClient = NotificationSettings.GetNotificationServiceFromSetConfiguration(); //VXMusicAPI.SetNotificationClient(notificationSettings.CurrentNotificationService);
78-
79-
81+
8082
VrChatNotification = NotificationSettings.GetVRChatNotificationClient();
8183

8284
PlaylistFileWriter = App.ServiceProvider.GetRequiredService<PlaylistFileWriter>();

0 commit comments

Comments
 (0)