:3
This commit is contained in:
parent
94d08a02d6
commit
4d1e69bbe5
8 changed files with 167 additions and 133 deletions
|
@ -5,7 +5,7 @@
|
|||
#include "macos/bridge.h"
|
||||
#include "os.h"
|
||||
|
||||
u64 GetMemInfo() {
|
||||
fn GetMemInfo() -> u64 {
|
||||
u64 mem = 0;
|
||||
usize size = sizeof(mem);
|
||||
|
||||
|
@ -14,7 +14,7 @@ u64 GetMemInfo() {
|
|||
return mem;
|
||||
}
|
||||
|
||||
std::string GetNowPlaying() {
|
||||
fn GetNowPlaying() -> std::string {
|
||||
if (const char* title = GetCurrentPlayingTitle();
|
||||
const char* artist = GetCurrentPlayingArtist())
|
||||
return "Now Playing: " + std::string(artist) + " - " + std::string(title);
|
||||
|
@ -22,6 +22,6 @@ std::string GetNowPlaying() {
|
|||
return "No song playing";
|
||||
}
|
||||
|
||||
const char* GetOSVersion() { return GetMacOSVersion(); };
|
||||
fn GetOSVersion() -> const char* { return GetMacOSVersion(); };
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,10 +9,12 @@
|
|||
+ (NSString*)macOSVersion;
|
||||
@end
|
||||
#else
|
||||
#include "util/numtypes.h"
|
||||
|
||||
extern "C" {
|
||||
const char* GetCurrentPlayingTitle();
|
||||
const char* GetCurrentPlayingArtist();
|
||||
const char* GetMacOSVersion();
|
||||
fn GetCurrentPlayingTitle() -> const char*;
|
||||
fn GetCurrentPlayingArtist() -> const char*;
|
||||
fn GetMacOSVersion() -> const char*;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -79,7 +79,8 @@ using MRMediaRemoteGetNowPlayingInfoFunction = void (*)(
|
|||
NSNumber* majorVersionNumber = @(osVersion.majorVersion);
|
||||
NSString* versionName = versionNames[majorVersionNumber];
|
||||
|
||||
if (versionName == nil) versionName = @"Unknown";
|
||||
if (versionName == nil)
|
||||
versionName = @"Unknown";
|
||||
|
||||
NSString* fullVersion =
|
||||
[NSString stringWithFormat:@"macOS %@ %@", version, versionName];
|
||||
|
@ -88,37 +89,44 @@ using MRMediaRemoteGetNowPlayingInfoFunction = void (*)(
|
|||
}
|
||||
@end
|
||||
|
||||
#include "util/numtypes.h"
|
||||
|
||||
extern "C" {
|
||||
const char* GetCurrentPlayingTitle() {
|
||||
fn GetCurrentPlayingTitle() -> const char* {
|
||||
NSDictionary* metadata = [Bridge currentPlayingMetadata];
|
||||
|
||||
if (metadata == nil) return nullptr;
|
||||
if (metadata == nil)
|
||||
return nullptr;
|
||||
|
||||
NSString* title =
|
||||
[metadata objectForKey:@"kMRMediaRemoteNowPlayingInfoTitle"];
|
||||
|
||||
if (title) return strdup([title UTF8String]);
|
||||
if (title)
|
||||
return strdup([title UTF8String]);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* GetCurrentPlayingArtist() {
|
||||
fn GetCurrentPlayingArtist() -> const char* {
|
||||
NSDictionary* metadata = [Bridge currentPlayingMetadata];
|
||||
|
||||
if (metadata == nil) return nullptr;
|
||||
if (metadata == nil)
|
||||
return nullptr;
|
||||
|
||||
NSString* artist =
|
||||
[metadata objectForKey:@"kMRMediaRemoteNowPlayingInfoArtist"];
|
||||
|
||||
if (artist) return strdup([artist UTF8String]);
|
||||
if (artist)
|
||||
return strdup([artist UTF8String]);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* GetMacOSVersion() {
|
||||
fn GetMacOSVersion() -> const char* {
|
||||
NSString* version = [Bridge macOSVersion];
|
||||
|
||||
if (version) return strdup([version UTF8String]);
|
||||
if (version)
|
||||
return strdup([version UTF8String]);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue