Unable to open camera in window 8 store app using c# - c#

I am the beginner on window 8 store app,still i am working on the app in which i have to open camera and capture the image, but when i try to execute following line of code, its throws following exception.
I am using following line of code
Windows.Media.Capture.CameraCaptureUI dialog = new CameraCaptureUI();
And throwing following exception
Requested Windows Runtime type 'Windows.Media.Capture.CameraCaptureUI' is not registered.
Please advise
thanks in advance

Maybe because you are on an emulator? Can you reproduce the error on a real device?

Related

Xamarin barcode app Zxing.Net.Mobile not working

I followed this tutorial "https://github.com/Redth/ZXing.Net.Mobile" when I use Live Preview and pair it with my android device and try to hit scan button the code breaks and it gives error like "Exception of type 'System.Collections.Generic.KeyNotFoundException' was thrown".
The error is thrown on very first line.
var scanPage = new ZXingScannerPage();
I 'm new to this one and not sure how to solve, if possible please let me know any barcode code which reads as well as scan in Visual studio 2017.
So I have checked in the github as well, its clear from forum that live preview has issues related to System.Collections.Generic.KeyNotFoundException so either have device connected or install some emulator and check.

NAudio - MediaFoundationReader: constructor doesn't take a delivered m4a-URL (from a youtube-Link)

I am trying to play an M4A (MP4 Audio) file directly from the internet using a URL.
I'm using NAudio with the MediaFoundation to achieve this:
using (var reader = new MediaFoundationReader(audioUrl)) //exception
using (var wave = new WaveOutEvent())
{
wave.Init(reader);
wave.Play();
}
This works well on two test systems with Windows 8.1 and Windows 10. But on my Windows 7 machine it is not working, I am getting an exception from inside the MediaFoundationReader constructor.
Initially, I was getting an ArgumentOutOfRangeException. I tested playing this m4a file in WMP and it was also unable to play it. I downloaded a codec pack and installed it. That helped with WMP but my code was still throwing an exception, albeit another one:
An unchecked exception of type
'System.Runtime.InteropServices.COMException' occurred in NAudio.dll
Additional information: There is more data available. (Exception from
HRESULT: 0x800700EA)
Any ideas what could be causing this and how I can fix it?
With some research i identified this
0X800700ea can occur when your Windows operating system becomes
corrupted. There can be numerous reason that this error occur
including excessive startup entries, registry errors, hardware/RAM
decline, fragmented files, unnecessary or redundant program
installations and so on.
Can you try you program in another system and verify
Sometimes the user doesn't have enough privileges to run COM Methods.
Try to run the application as Administrator.

Using the MediaCapture API, StartRecordToStorageFileAsync fails to return and does not raise an error

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.

Socket connection with Windows.Networking.Sockets and System.Net.Sockets

I am trying to create a simple Windows Phone 8.1 (hence Windows.Networking.Sockets) socket client, and Windows 8 server. Unfortunately I am quite new to this task, so I am having problems understanding the obstacles that appear.
I am using http://msdn.microsoft.com/pl-pl/library/fx6588te(v=vs.110).aspx this code as a server. However when it comes to the Windows Phone 8.1, it turned out that http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202858(v=vs.105).aspx this tutorial won't work, as there is no way to use the following import:
using System.Net.Sockets.
Which is the reason why i switched to the following code:
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj150599.aspx (which is btw quite sloppy, and full of errors)
So I embedded the Windows Phone 8.1 part of the code into my application, and it seems to connect correctly to the server, and it even sends data to the server, however the app crashes right after the following statement.
"Trying to send data"
And the output is exactly like the following:
A first chance exception of type 'System.ArgumentException' occured in Project.exe
WinRT information: count
Please help me solve the error, as I have vainly spent many hours trying to fix this..
EDIT
Here is the part of code from the mentioned tutorial, that throws the described error
// Now try to receive data from server
try
{
OutputView.Text = "";
StatusText.Text = "Trying to receive data ...";
DataReader reader = new DataReader(clientSocket.InputStream);
// Set inputstream options so that we don't have to know the data size
reader.InputStreamOptions = Partial;
await reader.LoadAsync(reader.UnconsumedBufferLength);
}

Obtain Access Into the Camera Roll Windows Phone 8

I am having an issue getting into the camera roll folder for Windows Phone 8. Unfortunately due to the project being a MonoGame Project, the MediaLibrary object is not implemented and thus does not work. I am left with having to directly tap into the camera roll folder directly, through I am getting an
Access Denied
Error as a result. The idea is that if I know the location of the file in the future, I can display it in certain parts of my app after the user has taken a photo using the app. The code is as follows:
StorageFile folder = await StorageFile.GetFileFromPathAsync("Pictures\\Camera Roll\\WP_20130227_001.jpg");
I have also checked off:
ID_MEDIALIB_PHOTO
and am still getting the error.
Any help is greatly appreciated!
Try using the photochoosertask..
PhotoChooserTask selectphoto = new PhotoChooserTask();
selectphoto.Completed += new EventHandler<PhotoResult>(selectphoto_Completed);
selectphoto.Show();
this might help.

Categories

Resources