Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am working in a phone system in C# using TAPI 3 library and I am looking to play a .wav file when called party answer the phone.

I found the following code, but I get an invalidcastexception in the line "myTerminalSupport = (ITTerminalSupport)ln;". "ln" is a TAPI3Lib.ITAddress type variable, which served to create the call previously.

Here is the code:

C#
ITCallInfo ici = (ITCallInfo)bcc;
ITTerminalSupport myTerminalSupport;
myTerminalSupport = (ITTerminalSupport)ln;
ITTerminal myTerminalForPlayback = myTerminalSupport.CreateTerminal(TapiConstants.CLSID_String_FilePlaybackTerminal, TapiConstants.TAPIMEDIATYPE_AUDIO,
TERMINAL_DIRECTION.TD_CAPTURE);
ITMediaPlayback myMedia = (ITMediaPlayback)myTerminalForPlayback;

object[] filelist = new object[2];

filelist[0] = "test.wav";

myMedia.PlayList = filelist;

ITBasicCallControl2 myCallControl2 = (ITBasicCallControl2)bcc;

myCallControl2.SelectTerminalOnCall(myTerminalForPlayback);

ITMediaControl myMediaControl = (ITMediaControl)myTerminalForPlayback;

myMediaControl.Start();
Posted
Updated 29-Dec-14 16:13pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900