I try to write a auto answer machin with TAPI in C#.NET.
I using tapi3_dev sample to work.this sample work in windows XP but in windows 7, everything is normal(no error or exception) but no sound playback just i can record the audio;
please help me.
my code::
case TAPI3Lib.ADDRESS_EVENT.AE_RINGING: this.PlayVoice(CallInfo);
...
private void PlayVoice(TAPI3Lib.ITCallInfo iTCallInfo)
{
try
{
//the supported file extensions are .avi and .wav. http://msdn.microsoft.com/en-us/library/ms730457.aspx
TAPI3Lib.ITBasicCallControl2 iTBasicCallControl2 = (TAPI3Lib.ITBasicCallControl2)iTCallInfo;
this.selectedTerminal = iTBasicCallControl2.RequestTerminal(TAPI3Lib.TapiConstants.CLSID_String_FilePlaybackTerminal, TAPI3Lib.TapiConstants.TAPIMEDIATYPE_AUDIO, TAPI3Lib.TERMINAL_DIRECTION.TD_CAPTURE);
TAPI3Lib.ITMediaPlayback iTMediaPlayback = (TAPI3Lib.ITMediaPlayback)this.selectedTerminal;
object[] playList = new object[1];
playList[0] = #"C:\ModemLog\7533f717-6cc5-41d5-9845-6983cff85e4b.avi";
//playList[0] = #"C:\Users\Abedi\Desktop\Anghezi.wav";
//playList[0] = #"C:\ProgramData\Venta\VentaFax & Voice 6\Service\greet1.wav";
iTMediaPlayback.PlayList = playList;
iTBasicCallControl2.SelectTerminalOnCall(this.selectedTerminal);
this.iTMediaControl = (TAPI3Lib.ITMediaControl)this.selectedTerminal;
if (iTCallInfo.CallState == TAPI3Lib.CALL_STATE.CS_OFFERING)
iTBasicCallControl2.Answer();
this.iTMediaControl.Start();
(selectedTerminal as TAPI3Lib.ITBasicAudioTerminal).Volume = 0;
}
catch (Exception exception)
{
this.Log(exception.Message, "Exception in PlayVoice");
this.WriteLine(exception.Message);
this.buttonDisconnect_Click(null, EventArgs.Empty);
}
}
Is your code running in a windows service? There is a known issue with audio control from a windows service under windows 7. Currently, I cannot find a work-around other than launcing a windows application to intergate with tapi.
Related
I'm trying to play the built-in webcam feed in a MediaElement within a UWP app. It works fine for a few users but there is no feed played for most and I'm lost on what could be the issue.
Some observations when the webcam feed doesn't play:
The code executes without any exceptions
The dialog that requests user permission to access the camera is shown
The LED indicating the webcam is in use turns on soon as it is executed, but there is no feed.
Skype and Camera apps work fine.
The app was working as expected until a week back. A few things that changed in the mean time that could have had an impact are
Installed Kaspersky
A bunch of windows updates
Uninstalled VS2017 professional edition & VS2019 Community edition and installed VS2019 Professional Edition
Some additional information that might be needed to narrow down the reason.
Webcam is enabled in the Package manifest of the app
App Target version: 18362
App Min version: 18362
Windows OS Version : 18362
Any help on this would be highly appreciated. Thanks much in advance!
Here is the piece of code used to play the webcam feed where VideoStreamer is a MediaElement.
private async Task PlayLiveVideo()
{
var allGroups = await MediaFrameSourceGroup.FindAllAsync();
var eligibleGroups = allGroups.Select(g => new
{
Group = g,
// For each source kind, find the source which offers that kind of media frame,
// or null if there is no such source.
SourceInfos = new MediaFrameSourceInfo[]
{
g.SourceInfos.FirstOrDefault(info => info.DeviceInformation?.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front
&& info.SourceKind == MediaFrameSourceKind.Color),
g.SourceInfos.FirstOrDefault(info => info.DeviceInformation?.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back
&& info.SourceKind == MediaFrameSourceKind.Color)
}
}).Where(g => g.SourceInfos.Any(info => info != null)).ToList();
if (eligibleGroups.Count == 0)
{
System.Diagnostics.Debug.WriteLine("No source group with front and back-facing camera found.");
return;
}
var selectedGroupIndex = 0; // Select the first eligible group
MediaFrameSourceGroup selectedGroup = eligibleGroups[selectedGroupIndex].Group;
MediaFrameSourceInfo frontSourceInfo = selectedGroup.SourceInfos[0];
MediaCapture mediaCapture = new MediaCapture();
MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings()
{
SourceGroup = selectedGroup,
SharingMode = MediaCaptureSharingMode.ExclusiveControl,
MemoryPreference = MediaCaptureMemoryPreference.Cpu,
StreamingCaptureMode = StreamingCaptureMode.Video,
};
try
{
await mediaCapture.InitializeAsync(settings);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("MediaCapture initialization failed: " + ex.Message);
return;
}
var frameMediaSource1 = MediaSource.CreateFromMediaFrameSource(mediaCapture.FrameSources[frontSourceInfo.Id]);
VideoStreamer.SetPlaybackSource(frameMediaSource1);
VideoStreamer.Play();
}
As mentioned by Faywang-MSFT here , it worked after marking the application as trusted in Kaspersky.
We have an UWP application and we would like to have the following scenario:
open Microsoft word from it with a document
edit document
close document and get data to our application.
We have an Silverlight application that uses the code below and resolves the problem nicely. Can we do something similar in UWP? Programmatically open Word and wait for instance closing.
private void SetupWordInstance(bool visible = true)
{
if (AutomationFactory.IsAvailable)
{
_wordApp = null;
try
{
_wordApp = AutomationFactory.CreateObject("Word.Application");
_wordVersion = _wordApp.Version;
}
catch
{
try
{
_wordApp = AutomationFactory.CreateObject("Word.Application");
_wordVersion = _wordApp.Version;
}
catch (Exception)
{
Utils.ShowMessage(Resource.MissingWordApplicationErrorMessage);
}
}
if (_wordApp != null)
{
AutomationEvent beforeCloseEvent = AutomationFactory.GetEvent(_wordApp, "DocumentBeforeClose");
beforeCloseEvent.AddEventHandler(new BeforeCloseAppDelegate(BeforeCloseApp));
AutomationEvent quitEvent = AutomationFactory.GetEvent(_wordApp, "Quit");
quitEvent.AddEventHandler(new QuitAppDelegate(QuitApp));
if (visible)
{
_wordApp.Visible = true;
_wordApp.Activate();
FocusWordInstance();
}
}
}
else
{
Utils.ShowMessage(Resource.MissingAutomationErrorMessage);
}
}
There is a possibility that it can correspond by the technology called desktop bridge which Microsoft provides. Here's an explanation. Easily, it is to extract the Windows Desktop function not available in UWP and provide it together with application.
Docs/Windows/UWP/Develop/Porting apps to Windows 10/Desktop Bridge
The following is a sample when using Excel.
Desktop app bridge to UWP Samples
UWP calling Office Interop APIs
Windows Application Packaging Project Samples
Excel.Interop
Since the definition of Word API is below, it seems that it can be used as above.
Microsoft.Office.Interop.Word Namespace
I want to set up a WiFiDirect connect between 2 windows 10 in a console application not in a universal app.
I set the target platform version to 10
<TargetPlatformVersion>10.0</TargetPlatformVersion>
I add the Reference to Windows.Foundation, Windows.Networking.Proximity, Windows.Networking.Sockets, Windows.Storage.Streams
In my application i check if WiFiDirect is suppartet.
if ((Windows.Networking.Proximity.PeerFinder.SupportedDiscoveryTypes & Windows.Networking.Proximity.PeerDiscoveryTypes.Browse) != Windows.Networking.Proximity.PeerDiscoveryTypes.Browse)
{
Console.WriteLine("Peer discovery using Wifi-Direct is not supported.\n");
}
This works as it should.
But when i call PeerFinder.Start() i get a exception .
HRESULT 0x80004004(E_ABORT)
This is the code calling PeerFinder.Start()
try
{
PeerFinder.AllowWiFiDirect = true;
PeerFinder.Role = PeerRole.Peer;
PeerFinder.ConnectionRequested += PeerFinder_ConnectionRequested;
PeerFinder.TriggeredConnectionStateChanged += PeerFinder_TriggeredConnectionStateChanged;
using (var discoveryDataWriter = new Windows.Storage.Streams.DataWriter(new Windows.Storage.Streams.InMemoryRandomAccessStream()))
{
discoveryDataWriter.WriteString("test12");
PeerFinder.DiscoveryData = discoveryDataWriter.DetachBuffer();
}
PeerFinder.Start();
}
catch (Exception e)
{
Console.WriteLine("start failed: " + e.Message);
}
i guess i can't use PeerFinder in a console application, are there any alternatives to establish a WiFiDirect connection for desktop applications?
I've developed a free UWP app with IAP included.
I developed this app for Windows 10 Mobile. I published an IAP to the store named customBackground, and published my app as well as the IAP to the store.
After both of them has published, I downloaded my published app from the store and try to buy the IAP.
However it returned an system popup saying "This in-app item is no longer availble in MY-APP-NAME". I don't know why this happened.
There are problems:
When I was trying in debug mode in visual studio using CurrentAppSimulator class, it doesn't popup the purchase state selection on my phone or emulator, but it pops up on desktop version. it only reads the stored state in WindowsStoreProxy.xml.
I've also tried using CurrentApp class in debug/release mode after the IAP is published, but no luck, it returns the same error as the store version.
internet permission in Package.appxmanifest is enabled.
Here's the code in my released app in the store:
private async void buy_Click(object sender, RoutedEventArgs e)
{
LicenseInformation licenseInformation = CurrentApp.LicenseInformation;
if (!licenseInformation.ProductLicenses["customBackground"].IsActive)
{
Debug.WriteLine("Buying this feature...");
try
{
await CurrentApp.RequestProductPurchaseAsync("customBackground");
if (licenseInformation.ProductLicenses["customBackground"].IsActive)
{
var purchaseStat = LocalizedStrings.GetString(LocalizedStringEnum.havePurchased);
var b = new MessageDialog(purchaseStat);
b.ShowAsync();
Debug.WriteLine("You bought this feature.");
isIAPValid = true;
}
else
{
var purchaseStat = LocalizedStrings.GetString(LocalizedStringEnum.notPurchased);
var b = new MessageDialog(purchaseStat);
b.ShowAsync();
Debug.WriteLine("this feature was not purchased.");
}
}
catch (Exception)
{
var purchaseStat = LocalizedStrings.GetString(LocalizedStringEnum.purchaseFailed);
var b = new MessageDialog(purchaseStat);
b.ShowAsync();
Debug.WriteLine("Unable to buy this feature.");
}
}
else
{
var purchaseStat = LocalizedStrings.GetString(LocalizedStringEnum.alreadyOwned);
var b = new MessageDialog(purchaseStat);
b.ShowAsync();
Debug.WriteLine("You already own this feature.");
isIAPValid = true;
}
}
Thanks!
Later after one day, I found my iap is working.
Seems like a temporary problem, Microsoft does need to improve their store system.
When we log in from guest account in Windows 8 and try to find the version it give error and the same value as Windows 8. Please suggest some code OR API which will work for both windows 8 and Windows 8.1
This gives you some background knowledge:
How can we check if the current OS is win8 or blue
And this is what works for me:
// this might only work as long as there's no successor to Windows 8.1
public Version GetVersion()
{
var reportedVersion = System.Environment.OSVersion.Version;
if (reportedVersion.Major==6 && reportedVersion.Minor==2)
{
bool _IsWindows8Point1OrGreater = Type.GetType("Windows.UI.Xaml.Controls.Flyout, Windows.UI.Xaml, ContentType=WindowsRuntime", false) != null;
if(_IsWindows8Point1OrGreater )
reportedVersion = new Version(6,3);
}
return reportedVersion;
}