UNPKG

@vonage/voice

Version:

The Voice API lets you create outbound calls, control in-progress calls and get information about historical calls.

93 lines (91 loc) 2.57 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // lib/classes/NCCO/Stream.ts var Stream_exports = {}; __export(Stream_exports, { Stream: () => Stream }); module.exports = __toCommonJS(Stream_exports); var Stream = class { /** * The action type for this NCCO action. */ action = "stream" /* STREAM */; /** * An array of stream URLs to play audio from. */ streamUrl; /** * The audio level at which to play the stream (optional). */ level; /** * Indicates whether the stream should allow barge-in (optional). */ bargeIn; /** * The number of times to loop the audio (optional). */ loop; /** * Creates a new Stream action. * * @param {string} streamUrl - The URL of the audio stream. * @param {number} [level] - The audio level at which to play the stream (optional). * @param {boolean} [bargeIn] - Indicates whether the stream should allow barge-in (optional). * @param {number} [loop] - The number of times to loop the audio (optional). */ constructor(streamUrl, level, bargeIn, loop) { this.streamUrl = [streamUrl]; if (level) { this.level = level; } if (bargeIn) { this.bargeIn = bargeIn; } if (loop) { this.loop = loop; } } /** * Serializes the Stream action to a Nexmo Call Control Object (NCCO). * * @return {StreamAction} - The serialized Stream action. */ serializeToNCCO() { const data = { action: "stream" /* STREAM */, streamUrl: this.streamUrl }; if (this.level) { data.level = this.level; } if (this.bargeIn) { data.bargeIn = this.bargeIn; } if (this.loop) { data.loop = this.loop; } return data; } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Stream });