Write the code

Add the following to VoiceController.cs:

Copy to Clipboard

varcall=Client.Call.Get(NEXMO_CALL_UUID);ViewData.Add("call",call);returnView();}[HttpPost]publicActionResultMuteCall(stringid){varNEXMO_CALL_UUID=Session["UUID"].ToString();varresult=Client.Call.Edit(NEXMO_CALL_UUID,newCall.CallEditCommand{action="mute"});returnRedirectToAction("MakeCall");}[HttpPost]publicActionResultUnmuteCall(stringid){varNEXMO_CALL_UUID=Session["UUID"].ToString();varresult=Client.Call.Edit(NEXMO_CALL_UUID,newCall.CallEditCommand{action="unmute"});returnRedirectToAction("MakeCall");}[HttpPost]publicActionResultEarmuffCall(stringid){varNEXMO_CALL_UUID=Session["UUID"].ToString();varresult=Client.Call.Edit(NEXMO_CALL_UUID,newCall.CallEditCommand{action="earmuff"});returnRedirectToAction("MakeCall");}[HttpPost]publicActionResultUnearmuffCall(stringid){varNEXMO_CALL_UUID=Session["UUID"].ToString();varresult=Client.Call.Edit(NEXMO_CALL_UUID,newCall.CallEditCommand{action="unearmuff"});returnRedirectToAction("MakeCall");}[HttpPost]publicActionResultHangupCall(){varNEXMO_CALL_UUID=Session["UUID"].ToString();varresult=Client.Call.Edit(NEXMO_CALL_UUID,newCall.CallEditCommand{action="hangup"});returnRedirectToAction("MakeCall");}[HttpPost]publicActionResultPlayttsToCall(){varNEXMO_CALL_UUID=Session["UUID"].ToString();varTEXT="This is a text to speech sample";varresult=Client.Call.BeginTalk(NEXMO_CALL_UUID,newCall.TalkCommand{text=TEXT,voice_name="Kimberly"});returnRedirectToAction("MakeCall");}[HttpPost]publicActionResultPlayAudioStreamToCall(){varNEXMO_CALL_UUID=Session["UUID"].ToString();varresult=Client.Call.BeginStream(NEXMO_CALL_UUID,newCall.StreamCommand{stream_url=new[]{"https://nexmo-community.github.io/ncco-examples/assets/voice_api_audio_streaming.mp3"}});returnRedirectToAction("MakeCall");}[HttpPost]publicActionResultPlayDTMFToCall(){varNEXMO_CALL_UUID=Session["UUID"].ToString();varDIGITS="1234";varresult=Client.Call.SendDtmf(NEXMO_CALL_UUID,newCall.DtmfCommand{digits=DIGITS});returnRedirectToAction("MakeCall");}}}