Details zum VOD-Anzeigen-Tag-Stitch abrufen

Rufen Sie Stitch-Details für ein Anzeigen-Tag für Video Stitcher-VOD-Sitzungen ab.

Weitere Informationen

Eine ausführliche Dokumentation, die dieses Codebeispiel enthält, finden Sie hier:

Codebeispiel

C#

Bevor Sie dieses Beispiel ausprobieren, folgen Sie der Einrichtungsanleitung für C# in der Video Stitcher API-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der C# API-Referenzdokumentation zur Video Stitcher API.

Richten Sie für die Authentifizierung bei der Video Stitcher API Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


using Google.Cloud.Video.Stitcher.V1;

public class GetVodStitchDetailSample
{
    public VodStitchDetail GetVodStitchDetail(
        string projectId, string location, string sessionId, string stitchDetailId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        GetVodStitchDetailRequest request = new GetVodStitchDetailRequest
        {
            VodStitchDetailName = VodStitchDetailName.FromProjectLocationVodSessionVodStitchDetail(projectId, location, sessionId, stitchDetailId)
        };

        // Call the API.
        VodStitchDetail vodStitchDetail = client.GetVodStitchDetail(request);

        // Return the result.
        return vodStitchDetail;
    }
}

Go

Bevor Sie dieses Beispiel ausprobieren, folgen Sie der Einrichtungsanleitung für Go in der Video Stitcher API-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Go API-Referenzdokumentation zur Video Stitcher API.

Richten Sie für die Authentifizierung bei der Video Stitcher API Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

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

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

// getVodStitchDetail gets the specified stitch detail for a video on demand (VOD) session.
func getVodStitchDetail(w io.Writer, projectID, sessionID, stitchDetailID string) error {
	// projectID := "my-project-id"
	// sessionID := "123-456-789"
	// stitchDetailID := "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.GetVodStitchDetailRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/vodSessions/%s/vodStitchDetails/%s", projectID, location, sessionID, stitchDetailID),
	}
	// Gets the stitch detail.
	response, err := client.GetVodStitchDetail(ctx, req)
	if err != nil {
		return fmt.Errorf("client.GetStitchDetail: %w", err)
	}
	b, err := json.MarshalIndent(response, "", " ")
	if err != nil {
		return fmt.Errorf("json.MarshalIndent: %w", err)
	}

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

Java

Bevor Sie dieses Beispiel ausprobieren, folgen Sie der Einrichtungsanleitung für Java in der Video Stitcher API-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Java API-Referenzdokumentation zur Video Stitcher API.

Richten Sie für die Authentifizierung bei der Video Stitcher API Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import com.google.cloud.video.stitcher.v1.GetVodStitchDetailRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodStitchDetail;
import com.google.cloud.video.stitcher.v1.VodStitchDetailName;
import java.io.IOException;

public class GetVodStitchDetail {

  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 stitchDetailId = "my-stitch-id";

    getVodStitchDetail(projectId, location, sessionId, stitchDetailId);
  }

  public static void getVodStitchDetail(
      String projectId, String location, String sessionId, String stitchDetailId)
      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. In this example, try-with-resources is used
    // which automatically calls close() on the client to clean up resources.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      GetVodStitchDetailRequest getVodStitchDetailRequest =
          GetVodStitchDetailRequest.newBuilder()
              .setName(
                  VodStitchDetailName.of(projectId, location, sessionId, stitchDetailId).toString())
              .build();

      VodStitchDetail response =
          videoStitcherServiceClient.getVodStitchDetail(getVodStitchDetailRequest);
      System.out.println("VOD stitch detail: " + response.getName());
    }
  }
}

Node.js

Bevor Sie dieses Beispiel ausprobieren, folgen Sie der Einrichtungsanleitung für Node.js in der Video Stitcher API-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Node.js API-Referenzdokumentation zur Video Stitcher API.

Richten Sie für die Authentifizierung bei der Video Stitcher API Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

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

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

async function getVodStitchDetail() {
  // Construct request
  const request = {
    name: stitcherClient.vodStitchDetailPath(
      projectId,
      location,
      sessionId,
      stitchDetailId
    ),
  };
  const [stitchDetail] = await stitcherClient.getVodStitchDetail(request);
  console.log(`VOD stitch detail: ${stitchDetail.name}`);
}

getVodStitchDetail();

PHP

Bevor Sie dieses Beispiel ausprobieren, folgen Sie der Einrichtungsanleitung für PHP in der Video Stitcher API-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der PHP API-Referenzdokumentation zur Video Stitcher API.

Richten Sie für die Authentifizierung bei der Video Stitcher API Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

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

/**
 * Gets the specified stitch 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 $stitchDetailId       The ID of the stitch detail
 */
function get_vod_stitch_detail(
    string $callingProjectId,
    string $location,
    string $sessionId,
    string $stitchDetailId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->vodStitchDetailName($callingProjectId, $location, $sessionId, $stitchDetailId);
    $request = (new GetVodStitchDetailRequest())
        ->setName($formattedName);
    $stitchDetail = $stitcherClient->getVodStitchDetail($request);

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

Python

Bevor Sie dieses Beispiel ausprobieren, folgen Sie der Einrichtungsanleitung für Python in der Video Stitcher API-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Python API-Referenzdokumentation zur Video Stitcher API.

Richten Sie für die Authentifizierung bei der Video Stitcher API Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import argparse

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

def get_vod_stitch_detail(
    project_id: str, location: str, session_id: str, stitch_detail_id: str
) -> stitcher_v1.types.VodStitchDetail:
    """Gets the specified stitch 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.
        stitch_detail_id: The ID of the stitch details.

    Returns:
        The VOD stitch detail resource.
    """

    client = VideoStitcherServiceClient()

    name = client.vod_stitch_detail_path(
        project_id, location, session_id, stitch_detail_id
    )
    response = client.get_vod_stitch_detail(name=name)
    print(f"VOD stitch detail: {response.name}")
    return response

Ruby

Bevor Sie dieses Beispiel ausprobieren, folgen Sie der Einrichtungsanleitung für Ruby in der Video Stitcher API-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Ruby API-Referenzdokumentation zur Video Stitcher API.

Richten Sie für die Authentifizierung bei der Video Stitcher API Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

require "google/cloud/video/stitcher"

##
# Get the specified stitch 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 stitch_detail_id [String] The stitch detail ID (e.g. "my-stitch-id")
#
def get_vod_stitch_detail project_id:, location:, session_id:, stitch_detail_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the VOD stitch detail.
  name = client.vod_stitch_detail_path project: project_id, location: location,
                                       vod_session: session_id,
                                       vod_stitch_detail: stitch_detail_id

  # Get the VOD stitch detail.
  stitch_detail = client.get_vod_stitch_detail name: name

  # Print the VOD stitch detail name.
  puts "VOD stitch detail: #{stitch_detail.name}"
end

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.