-
Notifications
You must be signed in to change notification settings - Fork 13
/
MPMediaItem-Properties.m
142 lines (116 loc) · 3.53 KB
/
MPMediaItem-Properties.m
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
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 3.0 Edition
BSD License, Use at your own risk
*/
#import "MPMediaItem-Properties.h"
/*
NSString *const MPMediaItemPropertyPersistentID; // filterable
NSString *const MPMediaItemPropertyMediaType; // filterable
NSString *const MPMediaItemPropertyTitle; // filterable
NSString *const MPMediaItemPropertyAlbumTitle; // filterable
NSString *const MPMediaItemPropertyArtist; // filterable
NSString *const MPMediaItemPropertyAlbumArtist; // filterable
NSString *const MPMediaItemPropertyGenre; // filterable
NSString *const MPMediaItemPropertyComposer; // filterable
NSString *const MPMediaItemPropertyPlaybackDuration;
NSString *const MPMediaItemPropertyAlbumTrackNumber;
NSString *const MPMediaItemPropertyAlbumTrackCount;
NSString *const MPMediaItemPropertyDiscNumber;
NSString *const MPMediaItemPropertyDiscCount;
NSString *const MPMediaItemPropertyArtwork;
NSString *const MPMediaItemPropertyLyrics;
NSString *const MPMediaItemPropertyIsCompilation; // filterable
NSString *const MPMediaItemPropertyPodcastTitle; // filterable
NSString *const MPMediaItemPropertyPlayCount;
NSString *const MPMediaItemPropertySkipCount;
NSString *const MPMediaItemPropertyRating;
NSString *const MPMediaItemPropertyLastPlayedDate;
*/
@implementation MPMediaItem (Properties)
- (long long) persistentID
{
return [[self valueForProperty:MPMediaItemPropertyPersistentID] longLongValue];
}
- (NSInteger) mediaType
{
return [[self valueForProperty:MPMediaItemPropertyMediaType] intValue];
}
- (NSString *) title
{
return [self valueForProperty:MPMediaItemPropertyTitle];
}
- (NSString *) albumTitle
{
return [self valueForProperty:MPMediaItemPropertyAlbumTitle];
}
- (NSString *) artist
{
return [self valueForProperty:MPMediaItemPropertyArtist];
}
- (NSString *) albumArtist
{
return [self valueForProperty:MPMediaItemPropertyAlbumArtist];
}
- (NSString *) genre
{
return [self valueForProperty:MPMediaItemPropertyGenre];
}
- (NSString *) composer
{
return [self valueForProperty:MPMediaItemPropertyComposer];
}
- (double) playbackDuration
{
return [[self valueForProperty:MPMediaItemPropertyPlaybackDuration] floatValue];
}
- (NSInteger) albumTrackNumber
{
return [[self valueForProperty:MPMediaItemPropertyAlbumTrackNumber] intValue];
}
- (NSInteger) albumTrackCount
{
return [[self valueForProperty:MPMediaItemPropertyAlbumTrackCount] intValue];
}
- (NSInteger) discNumber
{
return [[self valueForProperty:MPMediaItemPropertyDiscNumber] intValue];
}
- (NSInteger) discCount
{
return [[self valueForProperty:MPMediaItemPropertyDiscCount] intValue];
}
- (UIImage *) artwork
{
MPMediaItemArtwork *artwork = [self valueForProperty: MPMediaItemPropertyArtwork];
return [artwork imageWithSize:CGSizeMake(256.0f, 256.0f)];
}
- (NSString *) lyrics
{
return [self valueForProperty:MPMediaItemPropertyLyrics];
}
- (BOOL) isCompilation
{
return [[self valueForProperty:MPMediaItemPropertyIsCompilation] boolValue];
}
- (NSString *) podcastTitle
{
return [self valueForProperty:MPMediaItemPropertyPodcastTitle];
}
- (NSInteger) playCount
{
return [[self valueForProperty:MPMediaItemPropertyPlayCount] intValue];
}
- (NSInteger) skipCount
{
return [[self valueForProperty:MPMediaItemPropertySkipCount] intValue];
}
- (NSInteger) rating
{
return [[self valueForProperty:MPMediaItemPropertyRating] intValue];
}
- (NSDate *) lastPlayedDate
{
return [self valueForProperty:MPMediaItemPropertyLastPlayedDate];
}
@end