@@ -85,7 +85,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
85
85
}
86
86
87
87
- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
88
- NSInteger rows = 7 ;
88
+ NSInteger rows = 8 ;
89
89
@synchronized (_assets) {
90
90
if (_assets.count ) rows++;
91
91
}
@@ -110,7 +110,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
110
110
break ;
111
111
}
112
112
case 1 : {
113
- cell.textLabel .text = @" Multiple photos" ;
113
+ cell.textLabel .text = @" Multiple photos and video " ;
114
114
cell.detailTextLabel .text = @" with captions" ;
115
115
break ;
116
116
}
@@ -134,14 +134,19 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
134
134
cell.detailTextLabel .text = @" photos from web" ;
135
135
break ;
136
136
}
137
- case 6 : {
137
+ case 6 : {
138
138
cell.textLabel .text = @" Web photo grid" ;
139
139
cell.detailTextLabel .text = @" showing grid first" ;
140
140
break ;
141
141
}
142
- case 7 : {
143
- cell.textLabel .text = @" Library photos" ;
144
- cell.detailTextLabel .text = @" photos from device library" ;
142
+ case 7 : {
143
+ cell.textLabel .text = @" Web videos" ;
144
+ cell.detailTextLabel .text = @" showing grid first" ;
145
+ break ;
146
+ }
147
+ case 8 : {
148
+ cell.textLabel .text = @" Library photos and videos" ;
149
+ cell.detailTextLabel .text = @" media from device library" ;
145
150
break ;
146
151
}
147
152
default : break ;
@@ -158,7 +163,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
158
163
// Browser
159
164
NSMutableArray *photos = [[NSMutableArray alloc ] init ];
160
165
NSMutableArray *thumbs = [[NSMutableArray alloc ] init ];
161
- MWPhoto *photo;
166
+ MWPhoto *photo, *thumb ;
162
167
BOOL displayActionButton = YES ;
163
168
BOOL displaySelectionButtons = NO ;
164
169
BOOL displayNavArrows = NO ;
@@ -174,7 +179,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
174
179
enableGrid = NO ;
175
180
break ;
176
181
case 1 : {
177
- // Photos
182
+ // Local Photos and Videos
178
183
photo = [MWPhoto photoWithImage: [UIImage imageWithContentsOfFile: [[NSBundle mainBundle ] pathForResource: @" photo5" ofType: @" jpg" ]]];
179
184
photo.caption = @" Fireworks" ;
180
185
[photos addObject: photo];
@@ -183,7 +188,11 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
183
188
[photos addObject: photo];
184
189
photo = [MWPhoto photoWithURL: [NSURL fileURLWithPath: [[NSBundle mainBundle ] pathForResource: @" photo3" ofType: @" jpg" ]]];
185
190
photo.caption = @" York Floods" ;
186
- [photos addObject: photo];
191
+ [photos addObject: photo];
192
+ photo = [MWPhoto photoWithURL: [NSURL fileURLWithPath: [[NSBundle mainBundle ] pathForResource: @" video_thumb" ofType: @" jpg" ]]];
193
+ photo.videoURL = [NSURL fileURLWithPath: [[NSBundle mainBundle ] pathForResource: @" video" ofType: @" mp4" ]];
194
+ photo.caption = @" Big Buck Bunny" ;
195
+ [photos addObject: photo];
187
196
photo = [MWPhoto photoWithImage: [UIImage imageWithContentsOfFile: [[NSBundle mainBundle ] pathForResource: @" photo4" ofType: @" jpg" ]]];
188
197
photo.caption = @" Campervan" ;
189
198
[photos addObject: photo];
@@ -1015,6 +1024,42 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
1015
1024
startOnGrid = YES ;
1016
1025
break ;
1017
1026
case 7 : {
1027
+
1028
+ // Videos
1029
+
1030
+ photo = [MWPhoto photoWithURL: [[NSURL alloc ] initWithString: @" https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/e15/11192696_824079697688618_1761661_n.jpg" ]];
1031
+ photo.videoURL = [[NSURL alloc ] initWithString: @" https://scontent.cdninstagram.com/hphotos-xpa1/t50.2886-16/11200303_1440130956287424_1714699187_n.mp4" ];
1032
+ [photos addObject: photo];
1033
+ thumb = [MWPhoto photoWithURL: [[NSURL alloc ] initWithString: @" https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/s150x150/e15/11192696_824079697688618_1761661_n.jpg" ]];
1034
+ thumb.isVideo = YES ;
1035
+ [thumbs addObject: thumb];
1036
+
1037
+ // Test video with no poster frame
1038
+ // photo = [MWPhoto videoWithURL:[[NSURL alloc] initWithString:@"https://scontent.cdninstagram.com/hphotos-xfa1/t50.2886-16/11237510_945154435524423_2137519922_n.mp4"]];
1039
+ // [photos addObject:photo];
1040
+ // thumb = [MWPhoto new];
1041
+ // thumb.isVideo = YES;
1042
+ // [thumbs addObject:thumb];
1043
+
1044
+ photo = [MWPhoto photoWithURL: [[NSURL alloc ] initWithString: @" https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/e15/11240463_963135443745570_1519872157_n.jpg" ]];
1045
+ photo.videoURL = [[NSURL alloc ] initWithString: @" https://scontent.cdninstagram.com/hphotos-xfa1/t50.2886-16/11237510_945154435524423_2137519922_n.mp4" ];
1046
+ [photos addObject: photo];
1047
+ thumb = [MWPhoto photoWithURL: [[NSURL alloc ] initWithString: @" https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/11240463_963135443745570_1519872157_n.jpg" ]];
1048
+ thumb.isVideo = YES ;
1049
+ [thumbs addObject: thumb];
1050
+
1051
+ photo = [MWPhoto photoWithURL: [[NSURL alloc ] initWithString: @" https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/e15/11313531_1625089227727682_169403963_n.jpg" ]];
1052
+ photo.videoURL = [[NSURL alloc ] initWithString: @" https://scontent.cdninstagram.com/hphotos-xfa1/t50.2886-16/11336249_1783839318509644_116225363_n.mp4" ];
1053
+ [photos addObject: photo];
1054
+ thumb = [MWPhoto photoWithURL: [[NSURL alloc ] initWithString: @" https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/11313531_1625089227727682_169403963_n.jpg" ]];
1055
+ thumb.isVideo = YES ;
1056
+ [thumbs addObject: thumb];
1057
+
1058
+ // Options
1059
+ startOnGrid = YES ;
1060
+ break ;
1061
+ }
1062
+ case 8 : {
1018
1063
@synchronized (_assets) {
1019
1064
NSMutableArray *copy = [_assets copy ];
1020
1065
if (NSClassFromString (@" PHAsset" )) {
@@ -1196,7 +1241,7 @@ - (void)performLoadAssets {
1196
1241
dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
1197
1242
PHFetchOptions *options = [PHFetchOptions new ];
1198
1243
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey: @" creationDate" ascending: NO ]];
1199
- PHFetchResult *fetchResults = [PHAsset fetchAssetsWithMediaType: PHAssetMediaTypeImage options : options];
1244
+ PHFetchResult *fetchResults = [PHAsset fetchAssetsWithOptions : options];
1200
1245
[fetchResults enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) {
1201
1246
[_assets addObject: obj];
1202
1247
}];
0 commit comments