mac os
This commit is contained in:
parent
c9f28744c2
commit
8a6ff3db12
|
@ -1,24 +1,31 @@
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
|
#include <dispatch/dispatch.h>
|
||||||
#include "../MediaRemote.hpp"
|
#include "../MediaRemote.hpp"
|
||||||
#include "../backend.hpp"
|
#include "../backend.hpp"
|
||||||
|
|
||||||
std::shared_ptr<MediaInfo> backend::getMediaInformation() {
|
std::shared_ptr<MediaInfo> backend::getMediaInformation() {
|
||||||
|
std::string appName = "";
|
||||||
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
||||||
MRMediaRemoteGetNowPlayingApplicationPID(dispatch_get_main_queue(), ^(pid_t pid) {
|
MRMediaRemoteGetNowPlayingApplicationPID(dispatch_get_main_queue(), ^(pid_t pid) {
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
NSRunningApplication *app = [NSRunningApplication runningApplicationWithProcessIdentifier:pid];
|
NSRunningApplication *app = [NSRunningApplication runningApplicationWithProcessIdentifier:pid];
|
||||||
if (app) {
|
if (app)
|
||||||
NSLog(@"%@", app.bundleIdentifier);
|
appName = app.bundleIdentifier
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
dispatch_semaphore_signal(semaphore);
|
||||||
});
|
});
|
||||||
MRMediaRemoteGetNowPlayingInfo(dispatch_get_main_queue(), ^(CFDictionaryRef result) {
|
MRMediaRemoteGetNowPlayingInfo(dispatch_get_main_queue(), ^(CFDictionaryRef result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
NSDictionary *playingInfo = (__bridge NSDictionary *)(result);
|
NSDictionary *playingInfo = (__bridge NSDictionary *)(result);
|
||||||
NSLog(@"Now Playing Info: %@", playingInfo);
|
NSLog(@"Now Playing Info: %@", playingInfo);
|
||||||
}
|
}
|
||||||
|
dispatch_semaphore_signal(semaphore);
|
||||||
});
|
});
|
||||||
|
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
||||||
|
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
||||||
|
dispatch_release(semaphore);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
bool backend::toggleAutostart(bool enabled) { return false; }
|
bool backend::toggleAutostart(bool enabled) { return false; }
|
||||||
|
|
Loading…
Reference in New Issue