.NET
メイク・コール・アクションの追加
Voiceコントローラに新しいHTTPを追加する。 POST ルートで発信します。これを使ってNCCOと発信する。 stream アクション.このアクションは、以下の場所にあるオーディオファイルを再生します。 STREAM_URL を呼び出す。
にあるオーディオファイルを再生します。 STREAM_URL を呼び出す。
テストには https://raw.githubusercontent.com/nexmo-community/ncco-examples/gh-pages/assets/welcome_to_nexmo.mp3
以下のコードを VoiceController クラスである:
[HttpPost]
public IActionResult MakePhoneCall(string toNumber, string fromNumber)
{
const string STREAM_URL = "https://raw.githubusercontent.com/nexmo-community/ncco-examples/gh-pages/assets/welcome_to_nexmo.mp3";
var appId = _config["APPLICATION_ID"];
var privateKeyPath = _config["PRIVATE_KEY_PATH"];
var streamAction = new StreamAction{ StreamUrl = new string[] { STREAM_URL }};
var ncco = new Ncco(streamAction);
var toEndpoint = new PhoneEndpoint{Number=toNumber};
var fromEndpoint = new PhoneEndpoint{Number=fromNumber};
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath);
var client = new VoiceClient(credentials);
var callRequest = new CallCommand { To = new []{toEndpoint}, From = fromEndpoint, Ncco= ncco};
var call = client.CreateCall(callRequest);
ViewBag.Uuid = call.Uuid;
return View("Index");
}
.NETで通話中に音声を再生する
PSTN通話に音声を流すアプリの作り方を紹介するチュートリアル
手順
1
このチュートリアルの紹介2
Prerequisites3
.NET 音声アプリケーションの作成4
Vonageドットネットをインストールする5
音声コントローラーの追加6
メイク・コール・アクションの追加7
着信ルートを追加する8
ボイスビューの追加9
スタートアップ・ルートの設定10
ASP.NETアプリの設定11
.NETアプリの実行12
次はどうする?