MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

media/livestream/createChannelEvent.js:18–60  ·  view source on GitHub ↗
(projectId, location, channelId, eventId)

Source from the content-addressed store, hash-verified

16'use strict';
17
18function main(projectId, location, channelId, eventId) {
19 // [START livestream_create_channel_event]
20 /**
21 * TODO(developer): Uncomment these variables before running the sample.
22 */
23 // projectId = 'my-project-id';
24 // location = 'us-central1';
25 // channelId = 'my-channel';
26 // eventId = 'my-channel-event';
27
28 // Imports the Livestream library
29 const {LivestreamServiceClient} = require('@google-cloud/livestream').v1;
30
31 // Instantiates a client
32 const livestreamServiceClient = new LivestreamServiceClient();
33
34 async function createChannelEvent() {
35 // Construct request
36 const request = {
37 parent: livestreamServiceClient.channelPath(
38 projectId,
39 location,
40 channelId
41 ),
42 eventId: eventId,
43 event: {
44 adBreak: {
45 duration: {
46 seconds: 30,
47 },
48 },
49 executeNow: true,
50 },
51 };
52
53 // Run request
54 const [event] = await livestreamServiceClient.createEvent(request);
55 console.log(`Channel event: ${event.name}`);
56 }
57
58 createChannelEvent();
59 // [END livestream_create_channel_event]
60}
61
62// node createChannelEvent.js <projectId> <location> <channelId> <eventId>
63process.on('unhandledRejection', err => {

Callers 1

Calls 1

createChannelEventFunction · 0.85

Tested by

no test coverage detected