Mencantumkan detail penggabungan VOD

Mencantumkan semua detail penggabungan Penggabung Video untuk sesi VOD.

Jelajahi lebih lanjut

Untuk dokumentasi mendetail yang menyertakan contoh kode ini, lihat artikel berikut:

Contoh kode

C#

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan C# di panduan memulai Video Stitcher API menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API C# Video Stitcher API.

Untuk mengautentikasi ke Video Stitcher API, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


using Google.Api.Gax;
using Google.Cloud.Video.Stitcher.V1;

public class ListVodStitchDetailsSample
{
    public PagedEnumerable<ListVodStitchDetailsResponse, VodStitchDetail> ListVodStitchDetails(
        string projectId, string regionId, string sessionId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        ListVodStitchDetailsRequest request = new ListVodStitchDetailsRequest
        {
            ParentAsVodSessionName = VodSessionName.FromProjectLocationVodSession(projectId, regionId, sessionId)
        };

        // Make the request.
        PagedEnumerable<ListVodStitchDetailsResponse, VodStitchDetail> response = client.ListVodStitchDetails(request);

        // Return the result.
        return response;
    }
}

Go

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Go di panduan memulai Video Stitcher API menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Go Video Stitcher API.

Untuk mengautentikasi ke Video Stitcher API, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
	"google.golang.org/api/iterator"
)

// listVodStitchDetails lists the stitch details for a video on demand (VOD) session.
func listVodStitchDetails(w io.Writer, projectID, sessionID string) error {
	// projectID := "my-project-id"
	// sessionID := "123-456-789"
	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.ListVodStitchDetailsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s/vodSessions/%s", projectID, location, sessionID),
	}

	it := client.ListVodStitchDetails(ctx, req)
	fmt.Fprintln(w, "VOD stitch details:")
	for {
		response, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("it.Next(): %w", err)
		}
		fmt.Fprintln(w, response.GetName())
	}

	return nil
}

Java

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Java di panduan memulai Video Stitcher API menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Java Video Stitcher API.

Untuk mengautentikasi ke Video Stitcher API, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


import com.google.cloud.video.stitcher.v1.ListVodStitchDetailsRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodSessionName;
import com.google.cloud.video.stitcher.v1.VodStitchDetail;
import java.io.IOException;

public class ListVodStitchDetails {

  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";

    listVodStitchDetails(projectId, location, sessionId);
  }

  public static void listVodStitchDetails(String projectId, String location, String sessionId)
      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()) {
      ListVodStitchDetailsRequest listVodStitchDetailsRequest =
          ListVodStitchDetailsRequest.newBuilder()
              .setParent(VodSessionName.of(projectId, location, sessionId).toString())
              .build();

      VideoStitcherServiceClient.ListVodStitchDetailsPagedResponse response =
          videoStitcherServiceClient.listVodStitchDetails(listVodStitchDetailsRequest);
      System.out.println("VOD stitch details:");

      for (VodStitchDetail stitchDetail : response.iterateAll()) {
        System.out.println(stitchDetail.toString());
      }
    }
  }
}

Node.js

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Node.js di panduan memulai Video Stitcher API menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Node.js Video Stitcher API.

Untuk mengautentikasi ke Video Stitcher API, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

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

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

async function listVodStitchDetails() {
  // Construct request
  const request = {
    parent: stitcherClient.vodSessionPath(projectId, location, sessionId),
  };
  const iterable = await stitcherClient.listVodStitchDetailsAsync(request);
  console.log('VOD stitch details:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

listVodStitchDetails();

PHP

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan PHP di panduan memulai Video Stitcher API menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API PHP Video Stitcher API.

Untuk mengautentikasi ke Video Stitcher API, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

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

/**
 * Lists the stitch details for the specified 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
 */
function list_vod_stitch_details(
    string $callingProjectId,
    string $location,
    string $sessionId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->vodSessionName($callingProjectId, $location, $sessionId);
    $request = (new ListVodStitchDetailsRequest())
        ->setParent($formattedName);
    $response = $stitcherClient->listVodStitchDetails($request);

    // Print the stitch details list.
    $stitchDetails = $response->iterateAllElements();
    print('VOD stitch details:' . PHP_EOL);
    foreach ($stitchDetails as $stitchDetail) {
        printf('%s' . PHP_EOL, $stitchDetail->getName());
    }
}

Python

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Python di panduan memulai Video Stitcher API menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Python Video Stitcher API.

Untuk mengautentikasi ke Video Stitcher API, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


import argparse

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

def list_vod_stitch_details(
    project_id: str, location: str, session_id: str
) -> pagers.ListVodStitchDetailsPager:
    """Lists the stitch details for the specified VOD session.
    Args:
        project_id: The GCP project ID.
        location: The location of the session.
        session_id: The ID of the VOD session.

    Returns:
        An iterable object containing VOD stitch details resources.
    """

    client = VideoStitcherServiceClient()

    parent = client.vod_session_path(project_id, location, session_id)
    page_result = client.list_vod_stitch_details(parent=parent)
    print("VOD stitch details:")
    for response in page_result:
        print(response)

    return response

Ruby

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Ruby di panduan memulai Video Stitcher API menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Ruby Video Stitcher API.

Untuk mengautentikasi ke Video Stitcher API, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

require "google/cloud/video/stitcher"

##
# List the stitch details 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")
#
def list_vod_stitch_details project_id:, location:, session_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the parent.
  parent = client.vod_session_path project: project_id, location: location,
                                   vod_session: session_id

  # List all stitch details for the VOD session.
  response = client.list_vod_stitch_details parent: parent

  puts "VOD stitch details:"
  # Print out all VOD stitch details.
  response.each do |vod_stitch_detail|
    puts vod_stitch_detail.name
  end
end

Langkah selanjutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat browser contoh Google Cloud.