|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright 2022 Google LLC. |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +/** |
| 20 | + * For instructions on how to run the samples: |
| 21 | + * |
| 22 | + * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/media/videostitcher/README.md |
| 23 | + */ |
| 24 | + |
| 25 | +namespace Google\Cloud\Samples\Media\Stitcher; |
| 26 | + |
| 27 | +// [START videostitcher_create_slate] |
| 28 | +use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient; |
| 29 | +use Google\Cloud\Video\Stitcher\V1\Slate; |
| 30 | + |
| 31 | +/** |
| 32 | + * Creates a slate. A slate is displayed when ads are not available. |
| 33 | + * |
| 34 | + * @param string $callingProjectId The project ID to run the API call under |
| 35 | + * @param string $location The location of the slate |
| 36 | + * @param string $slateId The name of the slate to be created |
| 37 | + * @param string $slateUri The public URI for an MP4 video with at least one audio track |
| 38 | + */ |
| 39 | +function create_slate( |
| 40 | + string $callingProjectId, |
| 41 | + string $location, |
| 42 | + string $slateId, |
| 43 | + string $slateUri |
| 44 | +): void { |
| 45 | + // Instantiate a client. |
| 46 | + $stitcherClient = new VideoStitcherServiceClient(); |
| 47 | + |
| 48 | + $parent = $stitcherClient->locationName($callingProjectId, $location); |
| 49 | + $slate = new Slate(); |
| 50 | + $slate->setUri($slateUri); |
| 51 | + |
| 52 | + // Run slate creation request |
| 53 | + $response = $stitcherClient->createSlate($parent, $slateId, $slate); |
| 54 | + |
| 55 | + // Print results |
| 56 | + printf('Slate: %s' . PHP_EOL, $response->getName()); |
| 57 | +} |
| 58 | +// [END videostitcher_create_slate] |
| 59 | + |
| 60 | +// The following 2 lines are only needed to run the samples |
| 61 | +require_once __DIR__ . '/../../../testing/sample_helpers.php'; |
| 62 | +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); |
0 commit comments