forked from karelia/iMedia
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathIMBAppleMediaLibraryParser.h
191 lines (147 loc) · 5.5 KB
/
IMBAppleMediaLibraryParser.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//
// IMBAppleMediaLibraryParser.h
// iMedia
//
// Created by Jörg Jacobsen on 24.02.15.
//
//
#import <MediaLibrary/MediaLibrary.h>
#import <iMedia/iMedia.h>
#import "IMBParser.h"
typedef NSString IMBMLMediaGroupType;
// Eligible IMBMLMediaGroupType values
extern NSString *kIMBMLMediaGroupTypeAlbum;
extern NSString *kIMBMLMediaGroupTypeFolder;
extern NSString *kIMBMLMediaGroupTypeEventsFolder;
extern NSString *kIMBMLMediaGroupTypeFacesFolder;
#pragma mark -
@protocol IMBAppleMediaLibraryParserDelegate <NSObject>
#pragma mark Mandatory
/**
*/
- (void) setMediaSource:(MLMediaSource *)mediaSource;
/**
Returns the identifier for the app that is associated with sources handled by the parser. Must be subclassed.
@see MLMediaLibrary media source identifiers
*/
- (NSString *)mediaSourceIdentifier;
/**
Internal media type is specific to Apple Media Library based parsers and not to be confused with kIMBMediaTypeImage and its siblings.
*/
- (MLMediaType)mediaType;
/**
Returns the identifier for the app that is associated with sources handled by the parser.
*/
- (NSString *)sourceAppBundleIdentifier;
/**
Returns a set of group identifiers identifying all groups that were automatically created by the app that owns the media library.
*/
- (NSSet *)identifiersOfNonUserCreatedGroups;
/**
@return Type of media group provided unified across all possible media sources.
@discussion Default return value is kIMBMLMediaGroupTypeAlbum.
*/
- (IMBMLMediaGroupType *)typeForMediaGroup:(MLMediaGroup *)mediaGroup;
/**
Returns whether group (aka node) is populated with child group objects rather than real media objects.
*/
- (BOOL)shouldUseChildGroupsAsMediaObjectsForMediaGroup:(MLMediaGroup *)mediaGroup;
/**
*/
- (MLMediaObject *)keyMediaObjectForMediaGroup:(MLMediaGroup *)mediaGroup;
/**
*/
- (NSImage *)thumbnailForMediaObject:(MLMediaObject *)mediaObject;
/**
*/
- (NSImage *)thumbnailForMediaGroup:(MLMediaGroup *)mediaGroup;
#pragma mark Optional
@optional
/**
@return A thumbnail to be used as the image representation of object.
@parameter thumbnail The original thumbnail of the media object used by default
*/
- (NSImage *)thumbnailForObject:(IMBObject *)object baseThumbnail:(NSImage *)thumbnail;
/**
The name of the library used for display.
@discussion Default is the localized bundle name of the source app.
@see sourceAppBundleIdentifier
*/
- (NSString *)libraryName;
/**
Returns the URL denoting the actual media source on disk.
@discussion
If the URL is not accessible to a concrete parser it may return nil but implications of doing so are not yet fully understood.
*/
- (NSURL *)sourceURLForMediaGroup:(MLMediaGroup *)mediaGroup;
/**
Returns a dictionary of metadata for mediaObject.
@discussion Keys must conform to what's used in -...
*/
- (NSDictionary *)metadataForMediaObject:(MLMediaObject *)mediaObject;
/**
Returns a dictionary of metadata for mediaGroup.
@discussion Keys must conform to what's used in -...
*/
- (NSDictionary *)metadataForMediaGroup:(MLMediaGroup *)mediaGroup;
/**
Returns whether a media group should be displayed or not. Default is YES.
*/
- (BOOL)shouldUseMediaGroup:(MLMediaGroup *)mediaGroup;
/**
Returns whether a media group should reuse the media objects of its parent group or not. Default is No.
@discussion Reusing media objects may result in substantial performance increase when populating a node.
*/
- (BOOL)shouldReuseMediaObjectsOfParentGroupForGroup:(MLMediaGroup *)mediaGroup;
/**
Returns customized group icon for group type specified by typeIdentifier.
@discussion
If you don't implement this method or it returns nil then -[MLMediaGroup icon] will be utilized instead.
*/
- (NSImage *)groupIconForTypeIdentifier:(NSString *)typeIdentifier highlight:(BOOL)highlight;
/**
*/
- (NSString *)countFormatForGroup: (MLMediaGroup *)mediaGroup plural:(BOOL)plural;
@end
#pragma mark -
/**
Base class for parser classes that access their libraries through Apple's MediaLibrary framework. May be used as is. Must be configured through delegate.
*/
@interface IMBAppleMediaLibraryParser : IMBParser
{
MLMediaLibrary *_AppleMediaLibrary;
MLMediaSource *_AppleMediaSource;
id<IMBAppleMediaLibraryParserDelegate> _configuration;
}
/**
The root library object (providing possibly multiple media sources from different apps).
*/
@property (strong) MLMediaLibrary *AppleMediaLibrary;
/**
An MLMediaSource (an app's library) in Apple speak is not a mediaSource (a library's URL) in iMedia speak.
*/
@property (strong) MLMediaSource *AppleMediaSource;
@property (strong) id<IMBAppleMediaLibraryParserDelegate> configuration;
/**
Initializes Apple media library and media source for the receiver.
@discussion
Must be called in the initialization process of the receiver but must not be called before configuration of receiver is set.
*/
- (instancetype)initializeMediaLibrary;
/**
Converts from IMB media type to Apple Media Library media type.
*/
+ (MLMediaType)MLMediaTypeForIMBMediaType:(NSString *)mediaType;
/**
Returns whether the node given should be shown in the node hierarchy.
@discussion
This implementation always returns YES. You are welcome to override in your subclass parser.
*/
- (BOOL)shouldUseMediaGroup:(MLMediaGroup *)mediaGroup;
/**
Returns whether the group given should use the same media objects as its parent.
@discussion
This implementation always returns NO. You are welcome to override in your subclass parser (will boost performance).
*/
- (BOOL)shouldReuseMediaObjectsOfParentGroupForGroup:(MLMediaGroup *)mediaGroup;
@end