private void AnswerCall() { SetStatusMessage("Answering Call..."); if (playbackTerminal != null) { playbackTerminal.Dispose(); playbackTerminal = null; } // Get the playback terminal from the call try { playbackTerminal = activeCall.RequestTerminal(TTerminal.FilePlaybackTerminal, TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_CAPTURE); if (playbackTerminal != null) { playbackTerminal.MediaPlayList = new string[] { PLAY_FILENAME }; activeCall.SelectTerminalOnCall(playbackTerminal); activeCall.Answer(); } else { MessageBox.Show("Failed to retrieve playback terminal."); activeCall.Disconnect(DISCONNECT_CODE.DC_REJECTED); } } catch (TapiException ex) { MessageBox.Show(ex.Message); activeCall.Disconnect(DISCONNECT_CODE.DC_NORMAL); } }
private void OnFileTerminal(object sender, TapiFileTerminalEventArgs e) { // We are interested in TMS_IDLE because we will un-select playback and // select recording if (e.State == TERMINAL_MEDIA_STATE.TMS_IDLE) { if (e.Terminal.Direction == TERMINAL_DIRECTION.TD_RENDER && playbackTerminal != null) { try { // Remove the playback terminal currCall.UnselectTerminalOnCall(playbackTerminal); playbackTerminal.Dispose(); playbackTerminal = null; // Generate a custom tone on the call. currCall.GenerateCustomTones(new TCustomTone[] { new TCustomTone(700, 500, 0, 0xFFFF) }, 500); // Disconnect the call currCall.Disconnect(DISCONNECT_CODE.DC_NORMAL); } catch (TapiException ex) { MessageBox.Show(ex.Message); currCall.Disconnect(DISCONNECT_CODE.DC_NORMAL); } } } }