Latest Legacy

Play audio on a call

This endpoint allows you to play an audio file during an active call. VTS supports .mp3 and .wav audio files.

API Endpoint

POST https://api.vtscom.net/v1/Account/{auth_id}/Call/{call_uuid}/Play/

Arguments

urls Required

A URL or a list of comma-separated URLs linking to an .mp3 or .wav file.

length integer

The maximum length, in seconds, to play this audio file.

legs string

The call leg in which the audio is to be played.

Allowed values: aleg (first leg of the call), bleg (second leg of the call), or both.

Defaults to aleg.

loop boolean

When set to true, audio file plays indefinitely.

Defaults to false.

mix boolean

Used to determine the behavior of current call audio when the file is being played. If set to false, then participants cannot hear anyone speaking in the call until the play audio stops. If set to true, call audio and play audio are mixed and played.

Defaults to true.

Returns

Returns the acknowledgement that the audio file has started playing.

Response

HTTP Status Code: 202

{
  "message": "play started",
  "api_id": "07abfd94-58c0-11e1-86da-adf28403fe48"
}

Example Request

1
2
3
4
5
6
7
8
import vts

client = vts.RestClient('<auth_id>','<auth_token>')

response = client.calls.play(
    call_uuid='bc480f62-6d99-469e-b80e-090e620de824',
    urls='https://s3.amazonaws.com/vtscloud/music.mp3', )
print(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Example for Call Play Create
#
require 'rubygems'
require 'vts'

include vts
include vts::Exceptions

api = RestClient.new("<auth_id>","<auth_token>")

begin
  response = api.calls.play(
    'eba53b9e-8fbd-45c1-9444-696d2172fbc8',
    ['https://s3.amazonaws.com/vtscloud/Trumpet.mp3'],
    loop: true
  )
  puts response
rescue VTSRESTError => e
  puts 'Exception: ' + e.message
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Example for Call Play create

var vts = require('vts');

(function main() {
    'use strict';
    
   // If auth id and auth token are not specified, vts will fetch them from the environment variables.
    var client = new vts.Client("<auth_id>","<auth_token>");
    client.calls.playMusic(
        "eba53b9e-8fbd-45c1-9444-696d2172fbc8", // call uuid
        "https://s3.amazonaws.com/vtscloud/Trumpet.mp3", // urls
    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
/**
 * Example for Call Play create
 */
require 'vendor/autoload.php';
use vts\RestClient;
use vts\Exceptions\VTSRestException;
$client = new RestClient("<auth_id>","<auth_token>");

try {
    $response = $client->calls->startPlaying(
        'eba53b9e-8fbd-45c1-9444-696d2172fbc8',
        [
        	'https://s3.amazonaws.com/vtscloud/Trumpet.mp3',
        	'https://www.ANOTHER.ONE/SOUND.MP3'
        ]
    );
    print_r($response);
}
catch (VTSRestException $ex) {
    print_r($ex);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package net.vtscom.api.samples.call.play;

import java.io.IOException;
import java.util.Collections;

import net.vtscom.api.vts;
import net.vtscom.api.exceptions.VTSRestException;
import net.vtscom.api.models.call.Call;
import net.vtscom.api.models.call.actions.CallPlayCreateResponse;

/**
* Example for Call Play create
*/
class PlayCreate {
    public static void main(String [] args) {
        VTS.init("<auth_id>","<auth_token>");
        try {
            CallPlayCreateResponse response = Call.player("eba53b9e-8fbd-45c1-9444-696d2172fbc8", Collections.singletonList("https://s3.amazonaws.com/vtscloud/Trumpet.mp3"))
                .play();

            System.out.println(response);
        } catch (VTSRestException | IOException e) {
            e.printStackTrace();
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * Example for Call Play Create
 */
using System;
using System.Collections.Generic;
using VTS;
using vts.Exception;

namespace VTSExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new VTSApi("<auth_id>","<auth_token>");
            try
            {
                var response = api.Call.StartPlaying(
                    callUuid:"93b35e56-5b28-47fc-95aa-8536625d3ac1",
                    urls:new List<string>() {"https://s3.amazonaws.com/vtscloud/music.mp3"}
                );
                Console.WriteLine(response);
            }
            catch (VTSRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}
1
2
3
4
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{"urls":"https://s3.amazonaws.com/vtscloud/Trumpet.mp3"}' \
    https://api.vtscom.net/v1/Account/{auth_id}/Call/{call_uuid}/Play/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Example for Call Play create
package main

import (
	"fmt"

	"github.com/vts/vts-go/v7"
)

func main() {
	client, err := vts.NewClient("<auth_id>", "<auth_token>", &vts.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	response, err := client.Calls.Play(
		"eba53b9e-8fbd-45c1-9444-696d2172fbc8",
		vts.CallPlayParams{
			URLs: "https://s3.amazonaws.com/vtscloud/Trumpet.mp3",
		},
	)
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Printf("Response: %#v\n", response)
}