Visualizzare i dettagli dei tag annuncio VOD

Visualizza i dettagli di un tag annuncio per una sessione VOD stitching video.

Per saperne di più

Per la documentazione dettagliata che include questo esempio di codice, consulta quanto segue:

Esempio di codice

C#

Prima di provare questo esempio, segui le istruzioni di configurazione C# riportate nella guida rapida all'API Video Stitcher che utilizza le librerie client. Per saperne di più, consulta la documentazione di riferimento dell'API Video Stitcher C#.

Per autenticarti all'API Video Stitcher, configura le credenziali predefinite dell'applicazione. Per ulteriori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.


using Google.Cloud.Video.Stitcher.V1;

public class GetVodAdTagDetailSample
{
    public VodAdTagDetail GetVodAdTagDetail(
        string projectId, string location, string sessionId, string adTagDetailId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        GetVodAdTagDetailRequest request = new GetVodAdTagDetailRequest
        {
            VodAdTagDetailName = VodAdTagDetailName.FromProjectLocationVodSessionVodAdTagDetail(projectId, location, sessionId, adTagDetailId)
        };

        // Call the API.
        VodAdTagDetail vodAdTagDetail = client.GetVodAdTagDetail(request);

        // Return the result.
        return vodAdTagDetail;
    }
}

Go

Prima di provare questo esempio, segui le istruzioni di configurazione Go riportate nella guida rapida all'API Video Stitcher che utilizza le librerie client. Per saperne di più, consulta la documentazione di riferimento dell'API Video Stitcher Go.

Per autenticarti all'API Video Stitcher, configura le credenziali predefinite dell'applicazione. Per ulteriori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

import (
	"context"
	"encoding/json"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// getVodAdTagDetail gets the specified ad tag detail for a video on demand (VOD) session.
func getVodAdTagDetail(w io.Writer, projectID, sessionID, adTagDetailID string) error {
	// projectID := "my-project-id"
	// sessionID := "123-456-789"
	// adTagDetailID := "01234-56789"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.GetVodAdTagDetailRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/vodSessions/%s/vodAdTagDetails/%s", projectID, location, sessionID, adTagDetailID),
	}
	// Gets the ad tag detail.
	response, err := client.GetVodAdTagDetail(ctx, req)
	if err != nil {
		return fmt.Errorf("client.GetVodAdTagDetail: %w", err)
	}
	b, err := json.MarshalIndent(response, "", " ")
	if err != nil {
		return fmt.Errorf("json.MarshalIndent: %w", err)
	}

	fmt.Fprintf(w, "VOD ad tag detail:\n%s", string(b))
	return nil
}

Java

Prima di provare questo esempio, segui le istruzioni di configurazione Java riportate nella guida rapida all'API Video Stitcher che utilizza le librerie client. Per saperne di più, consulta la documentazione di riferimento dell'API Video Stitcher Java.

Per autenticarti all'API Video Stitcher, configura le credenziali predefinite dell'applicazione. Per ulteriori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.


import com.google.cloud.video.stitcher.v1.GetVodAdTagDetailRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodAdTagDetail;
import com.google.cloud.video.stitcher.v1.VodAdTagDetailName;
import java.io.IOException;

public class GetVodAdTagDetail {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String sessionId = "my-session-id";
    String adTagDetailId = "my-ad-tag-id";

    getVodAdTagDetail(projectId, location, sessionId, adTagDetailId);
  }

  // Gets an ad tag detail for a video on demand (VOD) session.
  public static VodAdTagDetail getVodAdTagDetail(
      String projectId, String location, String sessionId, String adTagDetailId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      GetVodAdTagDetailRequest getVodAdTagDetailRequest =
          GetVodAdTagDetailRequest.newBuilder()
              .setName(
                  VodAdTagDetailName.of(projectId, location, sessionId, adTagDetailId).toString())
              .build();

      VodAdTagDetail response =
          videoStitcherServiceClient.getVodAdTagDetail(getVodAdTagDetailRequest);
      System.out.println("VOD ad tag detail: " + response.getName());
      return response;
    }
  }
}

Node.js

Prima di provare questo esempio, segui le istruzioni di configurazione Node.js riportate nella guida rapida all'API Video Stitcher che utilizza le librerie client. Per saperne di più, consulta la documentazione di riferimento dell'API Video Stitcher Node.js.

Per autenticarti all'API Video Stitcher, configura le credenziali predefinite dell'applicazione. Per ulteriori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// sessionId = 'my-session-id';
// adTagDetailId = 'my-ad-tag-detail-id';

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function getVodAdTagDetail() {
  // Construct request
  const request = {
    name: stitcherClient.vodAdTagDetailPath(
      projectId,
      location,
      sessionId,
      adTagDetailId
    ),
  };
  const [adTagDetail] = await stitcherClient.getVodAdTagDetail(request);
  console.log(`VOD ad tag detail: ${adTagDetail.name}`);
}

getVodAdTagDetail().catch(err => {
  console.error(err.message);
  process.exitCode = 1;
});

PHP

Prima di provare questo esempio, segui le istruzioni di configurazione PHP riportate nella guida rapida all'API Video Stitcher che utilizza le librerie client. Per saperne di più, consulta la documentazione di riferimento dell'API Video Stitcher PHP.

Per autenticarti all'API Video Stitcher, configura le credenziali predefinite dell'applicazione. Per ulteriori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\GetVodAdTagDetailRequest;

/**
 * Gets the specified ad tag detail for the VOD session.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the session
 * @param string $sessionId            The ID of the session
 * @param string $adTagDetailId        The ID of the ad tag detail
 */
function get_vod_ad_tag_detail(
    string $callingProjectId,
    string $location,
    string $sessionId,
    string $adTagDetailId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->vodAdTagDetailName($callingProjectId, $location, $sessionId, $adTagDetailId);
    $request = (new GetVodAdTagDetailRequest())
        ->setName($formattedName);
    $adTagDetail = $stitcherClient->getVodAdTagDetail($request);

    // Print results
    printf('VOD ad tag detail: %s' . PHP_EOL, $adTagDetail->getName());
}

Python

Prima di provare questo esempio, segui le istruzioni di configurazione Python riportate nella guida rapida all'API Video Stitcher che utilizza le librerie client. Per saperne di più, consulta la documentazione di riferimento dell'API Video Stitcher Python.

Per autenticarti all'API Video Stitcher, configura le credenziali predefinite dell'applicazione. Per ulteriori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.


import argparse

from google.cloud.video import stitcher_v1
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    VideoStitcherServiceClient,
)


def get_vod_ad_tag_detail(
    project_id: str, location: str, session_id: str, ad_tag_detail_id: str
) -> stitcher_v1.types.VodAdTagDetail:
    """Gets the specified ad tag detail for a VOD session.
    Args:
        project_id: The GCP project ID.
        location: The location of the session.
        session_id: The ID of the VOD session.
        ad_tag_detail_id: The ID of the ad tag details.

    Returns:
        The VOD ad tag detail resource.
    """

    client = VideoStitcherServiceClient()

    name = client.vod_ad_tag_detail_path(
        project_id, location, session_id, ad_tag_detail_id
    )
    response = client.get_vod_ad_tag_detail(name=name)
    print(f"VOD ad tag detail: {response.name}")
    return response

Ruby

Prima di provare questo esempio, segui le istruzioni di configurazione Ruby riportate nella guida rapida all'API Video Stitcher che utilizza le librerie client. Per saperne di più, consulta la documentazione di riferimento dell'API Video Stitcher Ruby.

Per autenticarti all'API Video Stitcher, configura le credenziali predefinite dell'applicazione. Per ulteriori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

require "google/cloud/video/stitcher"

##
# Get the specified ad tag detail for a VOD session
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param session_id [String] The VOD session ID (e.g. `my-vod-session-id`)
# @param ad_tag_detail_id [String] The ad tag detail ID (e.g. `my-ad-tag-id`)
#
def get_vod_ad_tag_detail project_id:, location:, session_id:, ad_tag_detail_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the VOD ad tag detail.
  name = client.vod_ad_tag_detail_path project: project_id, location: location,
                                       vod_session: session_id,
                                       vod_ad_tag_detail: ad_tag_detail_id

  # Get the VOD ad tag detail.
  ad_tag_detail = client.get_vod_ad_tag_detail name: name

  # Print the VOD ad tag detail name.
  puts "VOD ad tag detail: #{ad_tag_detail.name}"
end

Passaggi successivi

Per cercare e filtrare i sample di codice per altri Google Cloud prodotti, consulta il Google Cloud browser di sample.