I have an exception only in one PC, in others all work fine, anyone know wher it is comming from?
dditional information: Requested Windows Runtime type
'Windows.Media.Capture.MediaCapture' is not registered.
This exception is showing only in modern style apps (windows strore app) in windows 8.1. In WPF or Windows Form apps camera works fine. Code is fine, because in other pc work great:) i install system one more time, but the exception still showing up.
Looking at Microsoft's Windows Universal Samples (https://github.com/Microsoft/Windows-universal-samples/blob/e13cf5dca497ad661706d150a154830666913be4/Samples/SpeechRecognitionAndSynthesis/cs/AudioCapturePermissions.cs#L35) shows following piece of code
try
{
// Request access to the microphone only, to limit the number of capabilities we need
// to request in the package manifest.
MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Audio;
settings.MediaCategory = MediaCategory.Speech;
MediaCapture capture = new MediaCapture();
await capture.InitializeAsync(settings);
}
catch (TypeLoadException)
{
// On SKUs without media player (eg, the N SKUs), we may not have access to the Windows.Media.Capture
// namespace unless the media player pack is installed. Handle this gracefully.
var messageDialog = new Windows.UI.Popups.MessageDialog("Media player components are unavailable.");
await messageDialog.ShowAsync();
return false;
}
So you have to install "Media player components".
I just had this issue with Windows 10. I had installed the N edition, but it looks like since it is missing Media Player, the classes related to MediaCapture are also missing.
As Hans Passant mentioned, the MediaCapture class was not registered in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsRuntime\ActivatableClassId.
I reinstalled Window 10 (not the N edition) and now the class is registered.
Related
To launch another specific app we can set the other app's package family name:
var options = new LauncherOptions();
options.TargetApplicationPackageFamilyName = packageFamilyName;
Uri uri = new Uri(protocol);
var succeeded = await Windows.System.Launcher.LaunchUriAsync(uri, options);
If the other app wasn't installed, Store download page opens. But this happens only on Windows 10 desktop, on the phone nothing happens, it just fails.
However if we remove options parameter it searches for any app on Store.
await Windows.System.Launcher.LaunchUriAsync(uri);
Is there anyway to have Desktop behavior on Mobile too? I mean open exactly a specific app not any app that registered for that protocol
The documentation states this is for Desktop only at this point in time. Potentially the feature will make it to Mobile (and other Windows flavours) in the future.
We're building a multi-platform (desktop- and tablet-computers) application targeting Windows 8.1 as well as 10. As we process spatial data, we offer the user the possibility to use his current location using the device's gps receiver. To allow easy adaption to the (hardware) environment, we placed the gps-logic (including the API-calls) into an external assembly that we load based on a configuration.
Recently we discovered some problems with the gps-module using the Geolocator from Windows.Devices.Geolocation-API under windows 10 (but previously running without problem on Windows 8.1), not delivering any location. Further investigation and RTFM showed up, that - under Windows 10 - we were obliged to call the RequestAccessAsync before calling for the location.
As the RequestAcessAsync-method isn't available in Windows 8.1, we decided to create a new assembly, targeting Windows 10 (and then easily being bound/used through our configuration), what worked quite well:
public Win10GpsProvider()
{
RequestAccessAsync();
}
public async void RequestAccessAsnyc()
{
//next line causes exception:
var request = await Geolocator.RequestAccessAsync();
switch (request)
{
// we don't even get here... :(
}
}
Only up to running into an exception that gets thrown as soon as the RequestAccessAsync-method is being called (in UI-thread), stating that the call has to be made in the context of an app container.
This operation is only valid in the context of an app container. (Exception from HRESULT: 0x8007109A)
The exception occurs on both, desktop as well as tablet (verified through remoted debugging).
Searching a bit more, adding the "location" as a required capability to the package.appxmanifest may help:
<Capabilities>
<Capability Name="location"/>
</Capabilities>
That's where we're actually stuck at the moment:
We don't have an UWP-application (and actually don't want/can change that, as we're targeting Win 8.1 as well and have a defined deployment workflow including setups)
We can't get the assembly run without exception as there is no UWP app/context
Is there a way to get a separate assembly that targets the Windows 10 version of the Windows.Devices.Geolocation-API and can be called/loaded by a Win32-application?
AFAIK, it is not doable to call RequestAcessAsync method and make it work in Windows 8.1 app.
But if you directly use Geoposition in windows 8.1 project, and run this windows 8.1 app on windows 10 device for example on desktop, the permission request dialog will also be displayed:
So there should be no problem if you don't call RequestAcessAsync method in windows 8.1 app.
But in case user choose "No" in this permission request dialog, we can catch the exception and launch the Setting page to force user to enable the Location setting for this app for example like this:
private Geolocator _geolocator = null;
private uint _desireAccuracyInMetersValue = 0;
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
try
{
var _cts = new CancellationTokenSource();
CancellationToken token = _cts.Token;
_geolocator = new Geolocator { DesiredAccuracyInMeters = _desireAccuracyInMetersValue };
Geoposition pos = await _geolocator.GetGeopositionAsync().AsTask(token);
// Subscribe to PositionChanged event to get updated tracking positions
_geolocator.PositionChanged += OnPositionChanged;
// Subscribe to StatusChanged event to get updates of location status changes
_geolocator.StatusChanged += OnStatusChanged;
}
catch (Exception ex)
{
await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
}
}
This code in windows 8.1 project works fine both on windows 8.1 device and windows 10 device. And I don't quite understand what is your Win32-application for here?
I am trying to play an audio stream from stream server in my windows phone app. I read on Microsoft Documentation that I have to reference an Audio Stream Agent.
I have these projects in my solution :
I've tried to reference a new project as Audio Streaming Agent in my Windows Phone 8.1 application
but I keeping receiving the error :
I read that I have to change the target framework, but there is no option for target framework in the AudioStreamAgent1 properties.
Also, Can I do this using an application that is not the Silverlight kind? Is there a way to do without using the Silverlight one?
The problem is that the AudioSteamAgent is targeted at WP Silverlight, and your actual app is WP8.1 (WinRT).
To create background audio in WP8.1, you will want to use the Background Media Player.
You can find a great guide for how to get started here.
But basically (without all the boilerplate code to wire everything up), it comes down to telling the BMP what to play (code is from the link above):
BackgroundMediaPlayer.Current.SetUriSource(new Uri("ms-appx:///Assets/Media/Ring02.wma"));
BackgroundMediaPlayer.Current.Play();
And telling the OS player controls what to show, and what to do when the user interacts with them:
systemmediatransportcontrol = SystemMediaTransportControls.GetForCurrentView();
systemmediatransportcontrol.ButtonPressed += systemmediatransportcontrol_ButtonPressed;
systemmediatransportcontrol.PropertyChanged += systemmediatransportcontrol_PropertyChanged;
systemmediatransportcontrol.IsEnabled = true;
systemmediatransportcontrol.IsPauseEnabled = true;
systemmediatransportcontrol.IsPlayEnabled = true;
systemmediatransportcontrol.IsNextEnabled = true;
systemmediatransportcontrol.IsPreviousEnabled = true;
This is all assuming that you want the user to be able to leave the app and have media continue to play. If you just want to stream audio/video while the user is in the app you can use the MediaElement control.
I'm trying to use this MediaCapture API sample:
https://code.msdn.microsoft.com/windowsapps/Media-Capture-Sample-adf87622
but when I press Start Record to record to a file, this line never returns:
await m_mediaCaptureMgr.StartRecordToStorageFileAsync(recordProfile, m_recordStorageFile);
And no error is thrown. This computer is a Cyberpower PC. The sample DOES work on my other windows 10 computer (a mac mini) though. I thought maybe it was a codec issue but can't find any information on installing codecs so maybe that is not it--not sure. Thank you for any help or information.
Additional Info: Creating a profile like this works:
MediaEncodingProfile recordProfile = null;
recordProfile = MediaEncodingProfile.CreateWmv(Windows.Media.MediaProperties.VideoEncodingQuality.Auto);
But calling CreateMp4 instead of CreateWmv does not work.
My suspicion is that there's something wrong with your particular installation's encoders. If you can upgrade to Windows 10, with Visual Studio 2015 you can develop universal apps. The same code should work without an issue.
The Application and Voice commands are not shown in Cortana when typing "what can I say?"
I am attempting to use Voice Commands in the Foreground with Cortana and am running the Cortana Voice Command Sample and have been unable to get Cortana to show the application or Open / Perform Voice commands for the application named "AdventureWorks".
I am using the Cortana Voice Command Sample which I am running from Visual Studio 2015 locally on Windows 10 in debug. According to this link this should create an unpackage version of the sample on my local machine that I should be able to see from the Start screen which I cannot.
I have activated Microphone under the capabilities of the app and included the en-GB resources.resw file and changed the Package.appxmanifest to the Default language of en-GB to match in an attempt to ensure that Cortana's language matches with the application to eliminate that as a potential issue.
Here is the link showing that a unpackaged version of the application should be visible in the Start screen after running the app from VS (with or without debugging):
How to deploy a Metro App to the Desktop?
Cortana Voice Commands Sample:
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CortanaVoiceCommand
Note:
The application is standard apart from me including the en-GB resource file, changing the package.appxmanifest location to en-GB and adding Microphone to the capabilities of the application. Developer mode has also been enabled on my pc.
Update: There are no exceptions happening when adding the vcd.xml to the VoiceCommandDefinitionManager.. It looks like it should be working..
I have also noticed that when running the sample I cannot see the picture of London or the microphone icon saying "listening" like in this video: https://channel9.msdn.com/Events/Build/2015/3-716 at 04:16
At this time google searches for "application not showing in Cortana" does not show any useful results.
Has anyone else had any luck getting this sample to work? or similar issues? Also are you using the en-GB version?
Any help or ideas would be appreciated
I have successfully tested the AdverntureWorks sample using en-US.
Also I have developed another sample regarding Cortana Foreground.
Basically I have created the VCD and then installed it:
protected async override void OnLaunched(LaunchActivatedEventArgs e)
{
...
// Install the VCD
try
{
StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(#"HomeControlCommands.xml");
await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("There was an error registering the Voice Command Definitions", ex);
}
}
And then handled the activation:
protected override void OnActivated(IActivatedEventArgs e)
{
// Handle when app is launched by Cortana
if (e.Kind == ActivationKind.VoiceCommand)
{
VoiceCommandActivatedEventArgs commandArgs = e as VoiceCommandActivatedEventArgs;
SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;
string voiceCommandName = speechRecognitionResult.RulePath[0];
string textSpoken = speechRecognitionResult.Text;
IReadOnlyList<string> recognizedVoiceCommandPhrases;
System.Diagnostics.Debug.WriteLine("voiceCommandName: " + voiceCommandName);
System.Diagnostics.Debug.WriteLine("textSpoken: " + textSpoken);
switch (voiceCommandName)
{
...
}
}
}
The detailed process is described here
I had exactly same issue.
Make sure you have microphone capabilities turned on for your Package.appxmanifest otherwise it doesn't work.
Tu turn it on select your Package.appxmanifest in Solution Explorer go to Capabilities and check Microphone.
More info: http://jamescroft.co.uk/blog/universal-windows-8-dev/how-to-get-your-apps-cortana-ready/
Hope this helps,
damtur
I had the same problem as you, as noted by DevEnitly, if your region is set, for example, to UK and in your VCD file your CommandSet's language is en-US it won't work, simply changing the CommandSet's language to us-gb (or whatever language fits your region) should do the trick (it did for me), also note that, if you want to support different languages you should add more CommandSets. Hope this solve your problems.