本文整理汇总了C#中Twilio.TwiML.TwilioResponse.Play方法的典型用法代码示例。如果您正苦于以下问题:C# TwilioResponse.Play方法的具体用法?C# TwilioResponse.Play怎么用?C# TwilioResponse.Play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twilio.TwiML.TwilioResponse
的用法示例。
在下文中一共展示了TwilioResponse.Play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Department
public HttpResponseMessage Department(string companyId, string id, string callSid)
{
var callWaitUrl = _accountSettings.GetSetting("CallWaitUrl");
var queueMessageUrl = _accountSettings.GetSetting("JoiningQueueMessageUrl");
var endPoint = _endpointResolverService.Get(int.Parse(id));
var response = new TwilioResponse();
response.Play(queueMessageUrl);
var attributes = new
{
action = "api/CallStatus/Update?callId=null",
method = "POST",
waitUrl = callWaitUrl
};
response.Enqueue($"Department_{endPoint.EndpointId}", attributes);
_callService.UpdateCallBySid(new Call
{
Sid = callSid,
CallStatus = CallStatus.Queued,
DateReceived = DateTime.Now,
QueueId = int.Parse(id)
});
_logger.Debug($"Twiml generated for call {callSid}. {response.Element}");
return Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
}
示例2: Play
public ActionResult Play(string recordingUrl)
{
var response = new TwilioResponse();
response.Play(recordingUrl);
return TwiML(response);
}
示例3: Index
// /Voice
public TwiMLResult Index(VoiceRequest request)
{
var response = new TwilioResponse();
response.Say("Hello. It's me.");
response.Play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3");
return TwiML(response);
}
示例4: Index
//
// GET: /LookupCompliment/
public ActionResult Index()
{
WebRequest request = WebRequest.Create("http://www.flatterist.com/compliments.json");
request.Method = "GET";
request.ContentType = "application/json; charset=utf-8";
string jsonData = string.Empty;
using (Stream s = request.GetResponse().GetResponseStream())
{
using (StreamReader sr = new StreamReader(s))
{
jsonData = sr.ReadToEnd();
}
}
var json = (IDictionary<string, object>)SimpleJson.DeserializeObject(jsonData);
var results = (List<object>)json["compliments"];
int randomNumber = new Random().Next(results.Count);
dynamic fileNameStuff = results[randomNumber];
dynamic fileName = fileNameStuff[0];
TwilioResponse tr = new TwilioResponse();
tr.Play("http://www.flatterist.com/" + fileName + ".mp3");
return TwiML(tr);
}
示例5: HandleRecord
// /Voice/HandleRecord
public TwiMLResult HandleRecord(VoiceRequest request)
{
var response = new TwilioResponse();
response.Say("Listen to your recorded message.");
response.Play(request.RecordingUrl);
response.Say("Goodbye.");
return TwiML(response);
}
示例6: Index
public TwiMLResult Index(VoiceRequest request)
{
// Get information about the incoming call, like the city associated
// with the phone number (if Twilio can discover it)
var city = request.FromCity;
var response = new TwilioResponse();
response.Say($"Never gonna give you up {city}", new {voice = "alice"});
response.Play("https://demo.twilio.com/docs/classic.mp3");
return TwiML(response);
}
示例7: SayOrPlay
internal void SayOrPlay(TwilioResponse response, string message)
{
if (isImplementedAsMP3)
{
response.Play(message);
}
else
{
response.Say(message, new { language = culture });
}
}
示例8: Index
// /Voice
public TwiMLResult Index(VoiceRequest request)
{
var response = new TwilioResponse();
response.Say("Hello. It's me.", new {voice = "alice", language = "en-GB"});
response.Play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3");
response.BeginGather(new {numDigits = "1", action = "/Voice/HandleGather"});
response.Say("To speak to a real person, press 1.\n" +
"Press 2 to record a message for a Twilio educator.\n" +
"Press any other key to start over.");
response.EndGather();
return TwiML(response);
}
示例9: WaitInQueue
public ActionResult WaitInQueue(string CurrentQueueSize, string QueuePosition)
{
var response = new TwilioResponse();
var context = GlobalHost.ConnectionManager.GetHubContext<Hubs.QueueHub>();
context.Clients.All.reportQueueSize(CurrentQueueSize);
response.Say(string.Format("You are number {0} in the queue. Please hold.", QueuePosition));
response.Play("http://demo.brooklynhacker.com/music/ramones.mp3");
return TwiML(response);
}
示例10: Inbound
public TwilioResponse Inbound()
{
var response = new TwilioResponse();
if (settings.WorkingHours != null && settings.WorkingHours.Enabled)
{
if (!(settings.WorkingHours.From <= DateTime.UtcNow.TimeOfDay && settings.WorkingHours.To >= DateTime.UtcNow.TimeOfDay))
{
return AddVoiceMail(response);
}
}
if (settings.AvailableOperators.Any())
{
if (!string.IsNullOrEmpty(settings.GreetingAudio))
{
response.Play(settings.GreetingAudio);
}
response.Enqueue(settings.Queue.Name, new { method = "GET", action = GetEcho("enqueue"), waitUrl = GetEcho("wait"), waitUrlMethod = "GET" });
}
return AddVoiceMail(response);
}
示例11: ListenToPublicBroadcasts
public TwilioResponse ListenToPublicBroadcasts(VoiceRequest request, int profileId, int idx)
{
var response = new TwilioResponse();
PublicBroadcast broadcast;
try
{
broadcast = broadcastManager.GetAll().Skip(idx).Take(1).FirstOrDefault();
}
catch (Exception)
{
broadcast = null;
}
if (broadcast == null)
{
response.Say("No more broadcasts found, returning to the main menu");
response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU));
return response;
}
var fromProfile = profileManager.GetProfile(broadcast.FromProfileId);
response.Say(string.Format("Playing broadcast from {0}", fromProfile.FullName));
response.Play(broadcast.Url);
response.BeginGather(new { action = ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCAST_RESPONSE_SELECTION, profileId, idx), playBeep = true, numDigits = 1 });
response.Say("Press one to reply privately to this broadcast.");
response.Say("Press two to reply publicly to this broadcast.");
response.Say("Press three to listen to the next broadcast.");
if (broadcast.BroadcastReplies.Count > 0)
{
response.Say("Press four to listen to responses to this broadcast");
}
response.EndGather();
return response;
}
示例12: Index
//
// GET: /Twilio/
public ActionResult Index()
{
var response = new TwilioResponse();
response.Play("http://cloud.faithcomesbyhearing.com/mp3audiobibles2/ENGESVO2DA/A19__090_Psalms______ENGESVO2DA.mp3");
return new TwiMLResult(response);
}
示例13: AddVoiceMail
private TwilioResponse AddVoiceMail(TwilioResponse response)
{
return settings.VoiceMail == null || !settings.VoiceMail.Enabled
? response
: response.Play(settings.VoiceMail.Url).Record(new { method = "GET", action = GetEcho("voiceMail"), maxLength = settings.VoiceMail.TimeOut });
}
示例14: PlayRecordedVoiceMessage
public TwilioResponse PlayRecordedVoiceMessage(VoiceRequest request, int profileId, int? recordingIdx)
{
var response = new TwilioResponse();
var voiceMessages = profileManager.GetRecordings(profileId);
if (voiceMessages == null || voiceMessages.Count == 0)
{
response.Say("You have no voice messages");
response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU));
return response;
}
if (recordingIdx.HasValue && recordingIdx.Value >= voiceMessages.Count)
{
response.Say("No more messages.");
response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU));
return response;
}
Recording voiceMessage;
if (recordingIdx.HasValue)
{
voiceMessage = voiceMessages[recordingIdx.Value];
}
else
{
recordingIdx = 0;
voiceMessage = voiceMessages[recordingIdx.Value];
}
try
{
var profile = profileManager.GetProfile(voiceMessage.FromProfileId);
response.Say(string.Format("Playing message {0} from {1}", recordingIdx + 1, profile.FullName));
}
catch (Exception)
{
response.Say(string.Format("Playing message {0}", recordingIdx + 1));
}
response.Play(voiceMessage.Url);
response.BeginGather(new { numDigits = 1, action = string.Format("/IVRMain/PlayRecordedMessage_Response?profileId={0}&recordingIdx={1}&fromProfileId={2}", profileId, recordingIdx.Value, voiceMessage.FromProfileId) });
response.Say("Press one to repeat this message");
response.Say("Press two to delete this message");
response.Say("Press three to reply to this message");
response.Say("Press four to go to the next message");
response.EndGather();
return response;
}
示例15: ConsultantAfterCallResponse
public TwiMLResult ConsultantAfterCallResponse(CallContextModel model, string digits)
{
var response = new TwilioResponse();
var message = ConferenceConst.AcctionCompleted;
var specialist = new UserDto();
var call = new CallDto();
bool canWaiveFee = true;
int transcriptSuccess = 2;
try
{
if (digits.Equals("2") || digits.Equals("3") || digits.Equals("4") || digits.Equals("5"))
{
call = Services.Call.GetByCallSid(Request["CallSid"]);
if (string.IsNullOrWhiteSpace(model.RecordUrl))
{
model.RecordSid = call.RecordSid;
model.RecordDuration = call.RecordDuration;
model.RecordUrl = call.RecordUrl;
}
// Get specialist
if (model.IsCustomer) // Caller is customer
{
specialist = Services.Users.GetUserById(model.ReceiverId);
}
else
{
specialist = Services.Users.GetUserById(model.CallerId);
}
int startingTime = Convert.ToInt32(Services.SystemConfig.GetByKey(ParamatricBusinessRules.STARTING_TIME.ToString()).Value);
if (call.Duration <= startingTime)
{
canWaiveFee = false;
}
}
switch (digits)
{
case "1": // Dictate your follow up action
var statusCallBack = Utilities.FormatLink(Url.Action("VoiceMail", "Conference", model));
Services.Call.RedirectToVoiceMail(Request["CallSid"], statusCallBack);
break;
case "2": // Transcript consultation
// Send transcription request
transcriptSuccess = SendTranscriptionRequest(specialist.Id.ToString(), specialist.UserName,
specialist.Email, call.RecordUrl,
call.RecordDuration, call.Booking);
if (transcriptSuccess == 0)
{
message = ConferenceConst.BalanceNotEnoughForTranscript;
}
else if (transcriptSuccess == 1)
{
message = ConferenceConst.TranscriptError;
}
break;
case "3": // Play consultation record
response.Pause(5);
response.Play(model.RecordUrl);
break;
case "4": // Play consultation record and transcription
// Play consultation record
response.Pause(5);
response.Play(model.RecordUrl);
// Send transcription request
transcriptSuccess = SendTranscriptionRequest(specialist.Id.ToString(), specialist.UserName,
specialist.Email, call.RecordUrl,
call.RecordDuration, call.Booking);
if (transcriptSuccess == 0)
{
message = ConferenceConst.BalanceNotEnoughForTranscript;
}
else if (transcriptSuccess == 1)
{
message = ConferenceConst.TranscriptError;
}
break;
case "5": // Waive consultation fee
if (canWaiveFee)
{
response.Redirect(Url.Action("WaiveFeeAction", model));
}
else
{
response.Redirect(Url.Action("ConsultantAfterCall", model));
//.........这里部分代码省略.........