2024-11-05 11:23:15 +01:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <Foundation/Foundation.h>
|
2024-11-05 11:29:02 +01:00
|
|
|
#include <AppKit/AppKit.h>
|
2024-11-05 11:33:18 +01:00
|
|
|
#include <dispatch/dispatch.h>
|
2024-11-05 11:23:15 +01:00
|
|
|
#include "../MediaRemote.hpp"
|
|
|
|
#include "../backend.hpp"
|
|
|
|
|
|
|
|
std::shared_ptr<MediaInfo> backend::getMediaInformation() {
|
2024-11-05 11:33:18 +01:00
|
|
|
std::string appName = "";
|
|
|
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
2024-11-05 11:29:02 +01:00
|
|
|
MRMediaRemoteGetNowPlayingApplicationPID(dispatch_get_main_queue(), ^(pid_t pid) {
|
|
|
|
if (pid > 0) {
|
|
|
|
NSRunningApplication *app = [NSRunningApplication runningApplicationWithProcessIdentifier:pid];
|
2024-11-05 11:33:18 +01:00
|
|
|
if (app)
|
|
|
|
appName = app.bundleIdentifier
|
2024-11-05 11:29:02 +01:00
|
|
|
}
|
2024-11-05 11:33:18 +01:00
|
|
|
dispatch_semaphore_signal(semaphore);
|
2024-11-05 11:29:02 +01:00
|
|
|
});
|
2024-11-05 11:23:15 +01:00
|
|
|
MRMediaRemoteGetNowPlayingInfo(dispatch_get_main_queue(), ^(CFDictionaryRef result) {
|
|
|
|
if (result) {
|
|
|
|
NSDictionary *playingInfo = (__bridge NSDictionary *)(result);
|
|
|
|
NSLog(@"Now Playing Info: %@", playingInfo);
|
|
|
|
}
|
2024-11-05 11:33:18 +01:00
|
|
|
dispatch_semaphore_signal(semaphore);
|
2024-11-05 11:23:15 +01:00
|
|
|
});
|
2024-11-05 11:33:18 +01:00
|
|
|
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
|
|
|
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
|
|
|
dispatch_release(semaphore);
|
2024-11-05 11:23:15 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
bool backend::toggleAutostart(bool enabled) { return false; }
|
|
|
|
#endif
|