A single URL or a list of comma separated URLs linking to an .mp3 or .wav file.
length integer
This is the maximum length to which playing this audio file should be restricted to. Length is provided in seconds.
legs string
The call leg in which the audio has to be played. This can take three values aleg (first leg of the call), bleg(second leg of the call) or both. The default value is aleg.
loop boolean
This flag when set to true will play the audio file indefinitely. By default it is set to false.
mix boolean
This flag is used to determine the behaviour of current call audio when the file is being played. If this is set to false then participants of the call would not be able to hear anyone speaking in the call until the Play is stopped. If set to true both call audio and the Play audio will be mixed and played. Defaults to true.
Returns
Returns the acknowledgement that audio file has started playing.
## Example for Call Play Create#require'rubygems'require'plivo'includePlivoincludePlivo::Exceptionsapi=RestClient.new("YOUR_AUTH_ID","YOUR_AUTH_TOKEN")beginresponse=api.calls.play('eba53b9e-8fbd-45c1-9444-696d2172fbc8',['https://s3.amazonaws.com/plivocloud/Trumpet.mp3'],loop: true)putsresponserescuePlivoRESTError=>eputs'Exception: '+e.messageend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Example for Call Play createvarplivo=require('plivo');(functionmain(){'use strict';// As the auth_id and auth_token are unspecified, Plivo will fetch them from the PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN environment variables.varclient=newplivo.Client();client.calls.playMusic("eba53b9e-8fbd-45c1-9444-696d2172fbc8",// call uuid"https://s3.amazonaws.com/plivocloud/Trumpet.mp3",// urls).then(function(response){console.log(response);},function(err){console.error(err);});})();
<?php/**
* Example for Call Play create
*/require'vendor/autoload.php';usePlivo\RestClient;usePlivo\Exceptions\PlivoRestException;$client=newRestClient("YOUR_AUTH_ID","YOUR_AUTH_TOKEN");try{$response=$client->calls->startPlaying('eba53b9e-8fbd-45c1-9444-696d2172fbc8',['https://s3.amazonaws.com/plivocloud/Trumpet.mp3','http://www.ANOTHER.ONE/SOUND.MP3']);print_r($response);}catch(PlivoRestException$ex){print_r($ex);}
packagecom.plivo.api.samples.call.play;importjava.io.IOException;importjava.util.Collections;importcom.plivo.api.Plivo;importcom.plivo.api.exceptions.PlivoRestException;importcom.plivo.api.models.call.Call;importcom.plivo.api.models.call.actions.CallPlayCreateResponse;/**
* Example for Call Play create
*/classPlayCreate{publicstaticvoidmain(String[]args){Plivo.init();try{CallPlayCreateResponseresponse=Call.player("eba53b9e-8fbd-45c1-9444-696d2172fbc8",Collections.singletonList("https://s3.amazonaws.com/plivocloud/Trumpet.mp3")).play();System.out.println(response);}catch(PlivoRestException|IOExceptione){e.printStackTrace();}}}
/**
* Example for Call Play Create
*/usingSystem;usingSystem.Collections.Generic;usingPlivo;usingPlivo.Exception;namespacePlivoExamples{internalclassProgram{publicstaticvoidMain(string[]args){varapi=newPlivoApi("YOUR_AUTH_ID","YOUR_AUTH_TOKEN");try{varresponse=api.Call.StartPlaying(callUuid:"93b35e56-5b28-47fc-95aa-8536625d3ac1",urls:newList<string>(){"https://s3.amazonaws.com/plivocloud/music.mp3"});Console.WriteLine(response);}catch(PlivoRestExceptione){Console.WriteLine("Exception: "+e.Message);}}}}
// Example for Call Play createpackagemainimport"fmt"import"github.com/plivo/plivo-go"funcmain(){client,err:=plivo.NewClient("","",&plivo.ClientOptions{})iferr!=nil{panic(err)}response,err:=client.Calls.Play("eba53b9e-8fbd-45c1-9444-696d2172fbc8",plivo.CallPlayParams{URLs:"https://s3.amazonaws.com/plivocloud/Trumpet.mp3",},)iferr!=nil{panic(err)}fmt.Printf("Response: %#v\n",response)}
importplivoAUTH_ID="Your AUTH ID"AUTH_TOKEN="Your AUTH TOKEN"p=plivo.RestAPI(AUTH_ID,AUTH_TOKEN)params={# The ID of the call
'call_uuid':'55309cee-821d-11e4-9a73-498d468c930b',# You can specify a single URL or a list of comma separated
# URLs linking to an mp3 or wav file
'urls':'https://s3.amazonaws.com/plivocloud/Trumpet.mp3'# Maximum length in seconds that the audio should be played.
# (Optional)
# 'length' : 30
}response=p.play(params)printstr(response)
# encoding: utf-8require'plivo'includePlivoAUTH_ID='MAXXXXXXXXXXXXXXXXXX'AUTH_TOKEN='MTUzZjA4NzhiYWNlOWExNTNlZGJmNzUwYWViYjc2'p=RestAPI.new(AUTH_ID,AUTH_TOKEN)params={# The ID of the call'call_uuid'=>'55309cee-821d-11e4-9a73-498d468c930b',# You can specify a single URL or a list of comma separated# URLs linking to an mp3 or wav file'urls'=>'https://s3.amazonaws.com/plivocloud/Trumpet.mp3'# Maximum length in seconds that the audio should be played.# (Optional)# 'length' => 30}response=p.play(params)putsresponse
varplivo=require('plivo');varp=plivo.RestAPI({authId:'Your AUTH ID',authToken:'Your AUTH TOKEN'});varparams={// The ID of the call'call_uuid':'55309cee-821d-11e4-9a73-498d468c930b',// You can specify a single URL or a list of comma separated// URLs linking to an mp3 or wav file'urls':'https://s3.amazonaws.com/plivocloud/Trumpet.mp3',// Maximum length in seconds that the audio should be played.// (Optional)// 'length' : 30}p.play(params,function(status,response){console.log('Status: ',status);console.log('API Response:',response);});
<?phprequire'vendor/autoload.php';usePlivo\RestAPI;$auth_id="Your AUTH_ID";$auth_token="Your AUTH_TOKEN";$p=newRestAPI($auth_id,$auth_token);$params=array(# The ID of the call'call_uuid'=>'55309cee-821d-11e4-9a73-498d468c930b',# You can specify a single URL or a list of comma separated# URLs linking to an mp3 or wav file'urls'=>'https://s3.amazonaws.com/plivocloud/Trumpet.mp3'# Maximum length in seconds that the audio should be played.# (Optional)# 'length' => 30);$response=$p->play($params);// Print the responseecho"Status : ";print_r($response['status']);echo"Response : ";print_r($response['response']);?>
importjava.util.LinkedHashMap;importcom.plivo.helper.api.client.*;importcom.plivo.helper.api.response.response.GenericResponse;importcom.plivo.helper.exception.PlivoException;publicclassPlayMusic{publicstaticvoidmain(String[]args){StringauthId="Your AUTH ID";StringauthToken="Your AUTH TOKEN";RestAPIapi=newRestAPI(authId,authToken,"v1");LinkedHashMap<String,String>parameters=newLinkedHashMap<String,String>();// The ID of the callparameters.put("call_uuid","55309cee-821d-11e4-9a73-498d468c930b");// You can specify a single URL or a list of comma separated// URLs linking to an mp3 or wav fileparameters.put("urls","https://s3.amazonaws.com/plivocloud/Trumpet.mp3");// Maximum length in seconds that the audio should be played.// (Optional)// parameters.put("length", 30);try{// Send the messageGenericResponsemsgResponse=api.play(parameters);// Print the responseSystem.out.println(msgResponse);}catch(PlivoExceptione){System.out.println(e.getLocalizedMessage());}}}
usingSystem;usingSystem.Collections.Generic;usingRestSharp;usingPlivo.API;namespaceplay_music{publicclassProgram{publicstaticvoidMain(string[]args){RestAPIplivo=newRestAPI("Your AUTH_ID","Your AUTH_TOKEN");IRestResponse<GenericResponse>resp=plivo.play(newDictionary<string,string>(){// The ID of the call{"call_uuid","55309cee-821d-11e4-9a73-498d468c930b"},// You can specify a single URL or a list of comma separated// URLs linking to an mp3 or wav file{"urls","https://s3.amazonaws.com/plivocloud/Trumpet.mp3"}// Maximum length in seconds that the audio should be played.// (Optional)// {"length", 30};});//Prints the responseConsole.Write(resp.Content);Console.ReadLine();}}}
// Example for Call Play createpackagemainimport"fmt"import"github.com/plivo/plivo-go"funcmain(){client,err:=plivo.NewClient("","",&plivo.ClientOptions{})iferr!=nil{panic(err)}response,err:=client.Calls.Play("eba53b9e-8fbd-45c1-9444-696d2172fbc8",plivo.CallPlayParams{URLs:"https://s3.amazonaws.com/plivocloud/Trumpet.mp3",},)iferr!=nil{panic(err)}fmt.Printf("Response: %#v\n",response)}
Rate this page
🥳 Thank you! It means a lot to us!
×
Help Us Improve
Thank you so much for rating the page, we would like to get your input for further improvements!