Search in sources :

Example 1 with VideoCreative

use of com.google.api.ads.admanager.axis.v202205.VideoCreative in project googleads-java-lib by googleads.

the class CreateVideoCreatives method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param advertiserId the ID of the advertiser (company) that all creatives will be assigned to.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 * @throws IOException if unable to get media data from the URL.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long advertiserId) throws IOException {
    // Get the CreativeService.
    CreativeServiceInterface creativeService = adManagerServices.get(session, CreativeServiceInterface.class);
    // Create creative size.
    Size size = new Size();
    size.setWidth(640);
    size.setHeight(360);
    size.setIsAspectRatio(false);
    // Create an image creative.
    VideoCreative videoCreative = new VideoCreative();
    videoCreative.setName("Video creative #" + new Random().nextInt(Integer.MAX_VALUE));
    videoCreative.setAdvertiserId(advertiserId);
    videoCreative.setDestinationUrl("https://google.com");
    videoCreative.setSize(size);
    videoCreative.setVideoSourceUrl("https://storage.googleapis.com/interactive-media-ads/media/android.mp4");
    videoCreative.setDuration(115000);
    // Create the creatives on the server.
    Creative[] creatives = creativeService.createCreatives(new Creative[] { videoCreative });
    for (Creative createdCreative : creatives) {
        System.out.printf("A creative with ID %d, name '%s', and type '%s'" + " was created and can be previewed at: %s%n", createdCreative.getId(), createdCreative.getName(), createdCreative.getClass().getSimpleName(), ((VideoCreative) createdCreative).getVastPreviewUrl());
    }
}
Also used : VideoCreative(com.google.api.ads.admanager.axis.v202202.VideoCreative) Random(java.util.Random) VideoCreative(com.google.api.ads.admanager.axis.v202202.VideoCreative) Creative(com.google.api.ads.admanager.axis.v202202.Creative) Size(com.google.api.ads.admanager.axis.v202202.Size) CreativeServiceInterface(com.google.api.ads.admanager.axis.v202202.CreativeServiceInterface)

Example 2 with VideoCreative

use of com.google.api.ads.admanager.axis.v202205.VideoCreative in project googleads-java-lib by googleads.

the class CreateVideoCreatives method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param advertiserId the ID of the advertiser (company) that all creatives will be assigned to.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 * @throws IOException if unable to get media data from the URL.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long advertiserId) throws IOException {
    // Get the CreativeService.
    CreativeServiceInterface creativeService = adManagerServices.get(session, CreativeServiceInterface.class);
    // Create creative size.
    Size size = new Size();
    size.setWidth(640);
    size.setHeight(360);
    size.setIsAspectRatio(false);
    // Create an image creative.
    VideoCreative videoCreative = new VideoCreative();
    videoCreative.setName("Video creative #" + new Random().nextInt(Integer.MAX_VALUE));
    videoCreative.setAdvertiserId(advertiserId);
    videoCreative.setDestinationUrl("https://google.com");
    videoCreative.setSize(size);
    videoCreative.setVideoSourceUrl("https://storage.googleapis.com/interactive-media-ads/media/android.mp4");
    videoCreative.setDuration(115000);
    // Create the creatives on the server.
    Creative[] creatives = creativeService.createCreatives(new Creative[] { videoCreative });
    for (Creative createdCreative : creatives) {
        System.out.printf("A creative with ID %d, name '%s', and type '%s'" + " was created and can be previewed at: %s%n", createdCreative.getId(), createdCreative.getName(), createdCreative.getClass().getSimpleName(), ((VideoCreative) createdCreative).getVastPreviewUrl());
    }
}
Also used : VideoCreative(com.google.api.ads.admanager.axis.v202205.VideoCreative) Random(java.util.Random) Creative(com.google.api.ads.admanager.axis.v202205.Creative) VideoCreative(com.google.api.ads.admanager.axis.v202205.VideoCreative) Size(com.google.api.ads.admanager.axis.v202205.Size) CreativeServiceInterface(com.google.api.ads.admanager.axis.v202205.CreativeServiceInterface)

Aggregations

Random (java.util.Random)2 Creative (com.google.api.ads.admanager.axis.v202202.Creative)1 CreativeServiceInterface (com.google.api.ads.admanager.axis.v202202.CreativeServiceInterface)1 Size (com.google.api.ads.admanager.axis.v202202.Size)1 VideoCreative (com.google.api.ads.admanager.axis.v202202.VideoCreative)1 Creative (com.google.api.ads.admanager.axis.v202205.Creative)1 CreativeServiceInterface (com.google.api.ads.admanager.axis.v202205.CreativeServiceInterface)1 Size (com.google.api.ads.admanager.axis.v202205.Size)1 VideoCreative (com.google.api.ads.admanager.axis.v202205.VideoCreative)1