adWordsServices.get(session, MediaServiceInterface.class);
int offset = 0;
// Create selector.
Selector selector = new Selector();
selector.setFields(new String[] {"MediaId", "Width", "Height", "MimeType"});
selector.setPaging(new Paging(offset, PAGE_SIZE));
selector.setOrdering(new OrderBy[] {new OrderBy("MediaId", SortOrder.ASCENDING)});
selector.setPaging(new Paging(offset, PAGE_SIZE));
// Create predicates.
Predicate typePredicate =
new Predicate("Type", PredicateOperator.IN, new String[] {"IMAGE", "VIDEO"});
selector.setPredicates(new Predicate[] {typePredicate});
MediaPage page = null;
do {
// Get all images.
page = mediaService.get(selector);
// Display images.
if (page != null && page.getEntries() != null) {
for (Media media : page.getEntries()) {
Map<MediaSize, Dimensions> dimensions = Maps.toMap(media.getDimensions());
System.out.println("Media with id '" + media.getMediaId() +
(!dimensions.isEmpty()
? "', dimensions '" + dimensions.get(MediaSize.FULL).getWidth() + "x"
+ dimensions.get(MediaSize.FULL).getHeight()
: "") + "', and MIME type '"
+ media.getMediaType() + "' was found.");
}
} else {
System.out.println("No images/videos were found.");
}
offset += PAGE_SIZE;
selector.getPaging().setStartIndex(offset);
} while (offset < page.getTotalNumEntries());
}