forked from karelia/iMedia
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIMBAppleMediaLibraryPropertySynchronizer.h
60 lines (47 loc) · 1.94 KB
/
IMBAppleMediaLibraryPropertySynchronizer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// IMBAppleMediaLibraryPropertySynchronizer.h
// iMedia
//
// Created by Jörg Jacobsen on 13.02.15.
//
//
#import <Foundation/Foundation.h>
#import <MediaLibrary/MediaLibrary.h>
/**
This class provides synchronous access to properties of certain objects of Apple's MediaLibrary framework that by design reliably return values only asynchronously through KVO ("mediaSources" and friends).
Synchronous access to these properties is of great value for MediaLibrary-based iMedia parsers since parsers must return values synchronously to their client classes.
*/
@interface IMBAppleMediaLibraryPropertySynchronizer : NSObject
{
id _observedObject;
NSString *_key;
id _valueForKey;
dispatch_semaphore_t _semaphore;
}
/**
Returns value for given key of object synchronously.
Must not be called from main thread for keys like "mediaSources", "rootMediaGroup", "mediaObjects"
since it would block main thread forever!
*/
+ (id)synchronousValueForObservableKey:(NSString *)key ofObject:(id)object;
/**
Synchronously retrieves all media sources for mediaLibrary.
This method must not be called from the main thread since it would block the main thread forever!
*/
+ (NSDictionary *)mediaSourcesForMediaLibrary:(MLMediaLibrary *)mediaLibrary;
/**
Synchronously retrieves media root group for mediaSource.
This method must not be called from the main thread since it would block the main thread forever!
*/
+ (MLMediaGroup *)rootMediaGroupForMediaSource:(MLMediaSource *)mediaSource;
/**
Synchronously retrieves all media objects for mediaGroup.
This method must not be called from the main thread since it would block the main thread forever!
*/
+ (NSArray *)mediaObjectsForMediaGroup:(MLMediaGroup *)mediaGroup;
/**
Synchronously retrieves icon image for mediaGroup.
This method must not be called from the main thread since it would block the main thread forever!
*/
+ (NSImage *)iconImageForMediaGroup:(MLMediaGroup *)mediaGroup;
@end