Search in sources :

Example 1 with GeoPoint

use of com.google.api.services.youtube.model.GeoPoint in project api-samples by youtube.

the class GeolocationSearch method prettyPrint.

/*
     * Prints out all results in the Iterator. For each result, print the
     * title, video ID, location, and thumbnail.
     *
     * @param iteratorVideoResults Iterator of Videos to print
     *
     * @param query Search query (String)
     */
private static void prettyPrint(Iterator<Video> iteratorVideoResults, String query) {
    System.out.println("\n=============================================================");
    System.out.println("   First " + NUMBER_OF_VIDEOS_RETURNED + " videos for search on \"" + query + "\".");
    System.out.println("=============================================================\n");
    if (!iteratorVideoResults.hasNext()) {
        System.out.println(" There aren't any results for your query.");
    }
    while (iteratorVideoResults.hasNext()) {
        Video singleVideo = iteratorVideoResults.next();
        Thumbnail thumbnail = singleVideo.getSnippet().getThumbnails().getDefault();
        GeoPoint location = singleVideo.getRecordingDetails().getLocation();
        System.out.println(" Video Id" + singleVideo.getId());
        System.out.println(" Title: " + singleVideo.getSnippet().getTitle());
        System.out.println(" Location: " + location.getLatitude() + ", " + location.getLongitude());
        System.out.println(" Thumbnail: " + thumbnail.getUrl());
        System.out.println("\n-------------------------------------------------------------\n");
    }
}
Also used : GeoPoint(com.google.api.services.youtube.model.GeoPoint) Video(com.google.api.services.youtube.model.Video) Thumbnail(com.google.api.services.youtube.model.Thumbnail)

Aggregations

GeoPoint (com.google.api.services.youtube.model.GeoPoint)1 Thumbnail (com.google.api.services.youtube.model.Thumbnail)1 Video (com.google.api.services.youtube.model.Video)1