I created a simple Xamarin MonoMac Mac application ( bare bones 1 window ). I am trying to get a preview of my webcam onto the Main Window of the application. I use the AVFoundation classes to get access to the webcam.
I can successfully connect to the mac's webcam, and the webcam light turns on but I get no video on the Main Window.
My c# code
session = new AVCaptureSession () { SessionPreset = AVCaptureSession.PresetMedium };
var captureDevice = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video);
var input = AVCaptureDeviceInput.FromDevice (captureDevice);
if (input == null){
Console.WriteLine ("No input - this won't work on the simulator, try a physical device");
}
session.AddInput (input);
AVCaptureVideoPreviewLayer captureVideoPreviewLayer = new AVCaptureVideoPreviewLayer (session);
**//----> preview layer onto Window here ?!**
session.StartRunning ();
This fixed it - hopefully it will help someone ..
AVCaptureVideoPreviewLayer captureVideoPreviewLayer = AVCaptureVideoPreviewLayer.FromSession (session);
this.Window.ContentView.Layer=captureVideoPreviewLayer;
this.Window.ContentView.WantsLayer=true;
session.StartRunning ();
Related
I am running into an issue with my C# WPF application crashing silently when I am trying to play on 16 VideoViews. I did not see any error messaged popup, nor did I see anything in Windows Event viewer.
Each player instance have WindowsFormHost and hosting a VideoView in that and I am playing RTSP streams on them.
Crash time is not fixed, sometimes it crash after 2 hours, and sometimes after 7-8 hours.
Core.Initialize(AppInfo.VlcDir.FullName);
private LibVLC libVlc = null;
private LibVLCSharp.Shared.MediaPlayer mediaPlayer = null;
this.libVlc = new LibVLC(this.GetParsedPlayerOptions().ToArray());
this.mediaPlayer = new LibVLCSharp.Shared.MediaPlayer(this.libVlc);
this.videoPlayer.MediaPlayer = this.mediaPlayer;
this.mediaPlayer.Volume = 0;
this.mediaPlayer.EnableKeyInput = false;
this.mediaPlayer.EnableMouseInput = false;
// Then I added a bunch of event handlers for VideoView and MediaPlayer.
// Then I have a different function which plays videos
if (this.mediaPlayer != null)
{
var media = new Media(this.libVlc,GetPlaybackStreamUrl(this.Server), FromType.FromLocation);
this.mediaPlayer.Media = media;
this.mediaPlayer.Play();
try
{
media.Dispose();
}
catch
{
}
}
Please let me know if you need any more information.
Any suggestions of what I could be doing wrong, or anything missing?
I am running on Windows 10. Visual Studio 2019, application compiled as X86.
I am not able to find the option to upload log file, but I did attach that to the issue on videolan forum, which can be found here: https://code.videolan.org/videolan/LibVLCSharp/-/issues/564
Thanks.
I was not able to find the problem with the code or the crash stack for where it's dying.
But I was able to fix the problem by increasing the address space, by using editbin to add /LARGEADDRESSSPACE to process post build.
I have Lumia 830 and i've tried to create flashlight app in UWP C#. my device Flashlight works great but i don't know why i can't create my own app turn on / off Torch of my phone.
I use Lamp class :
var lamp = await Lamp.GetDefaultAsync();
if (lamp == null)
{
ShowErrorMessage("No Lamp device found");
return;
}
lamp.IsEnabled = true;
when run this code on my phone "lamp" is null and it couldn't find my FlashLED. I've got this code from MSDN.Microsoft.com and thay said
If the returned object is null, the Lamp API is unsupported on the
device. Some devices may not support the Lamp API even if there is a
lamp physically present on the device.
This class doesn't work on my Lumia 830 i don't kno why? :(
also i use this code :
var mediaDev = new MediaCapture();
await mediaDev.InitializeAsync();
var videoDev = mediaDev.VideoDeviceController;
var tc = videoDev.TorchControl;
if (tc.Supported)
{
// But wait, for this to work with Blue camera drivers, we have to Start a recording session
// Create video encoding profile as MP4
var videoEncodingProperties = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga);
// Start Video Recording
var videoStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync("tempVideo.mp4", CreationCollisionOption.GenerateUniqueName);
await mediaDev.StartRecordToStorageFileAsync(videoEncodingProperties, videoStorageFile);
// Turn on Torch
mediaDev.VideoDeviceController.TorchControl.Enabled = true;
}
this code works and my FlashLED turn on but it record video and it take's user SD Card memory.
please help me if you know there is best way to turn on/off Torch or FlashLED.
thanks in advance
Hussein Habibi Juybari
The Lamp API is designed for Windows 10 devices only and you can only use it on devices which support the API. Currently supported devices are 950/950XL, 650, and 550. Older devices will not be updated to support this API. You should fall back to the Windows 8.1 method of turning on flash when you detect that the lamp device is not available on older devices.
From: https://wpdev.uservoice.com/forums/110705/suggestions/15846967
Please test default sample named LampDevice (cf. https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/LampDevice). Do you have the same behavior ? I just tested on Lumia 930 it works fine. No Lumia 830 to test it.
I made the app in which I use method public static IAsyncOperation<SetImageFeedResult> RequestSetImageFeedAsync(Uri syndicationFeedUri) to play lock screen slideshow from external RSS feed in Windows 8. I use next Uri https://urzagatherer.azure-mobile.net/api/wallpapers and it works perfectly in Windows 8 (8.1). But when I run my App in Windows 10 and set the same Uri, lock screen slideshow doesn't play. Could somebody tell me, what is the problem?
I use following code:
SetImageFeedResult result = await LockScreen.RequestSetImageFeedAsync(new Uri("https://urzagatherer.azure-mobile.net/api/wallpapers"));
if (result == SetImageFeedResult.Success)
{
AddImageFeedScenarioOutputText.Text = "Called RequestSetImageFeedAsync: the specified URL was set as the default.";
}
else if (result == SetImageFeedResult.ChangeDisabled)
{
AddImageFeedScenarioOutputText.Text = "Called RequestSetImageFeedAsync: call succeeded but group policy has the lock screen image slide show turned off.";
}
else // (result == SetImageFeedResult.UserCanceled)
{
AddImageFeedScenarioOutputText.Text = "Called RequestSetImageFeedAsync: the specified URL was not set as the default.";
}
result is always equal SetImageFeedResult.Success
For your question, it seems that this method is working with windows 8.1 only
From Microsoft Docs:
LockScreen.RequestSetImageFeedAsync(Uri)
Registers an RSS image feed to be used as a lock screen slideshow. (Windows 8.1 only)
I am developing an app in unity in which the user can take photos using their device camera. This is working great using Unity's webcamtexture. However, there is no flash support for webcamtexture, so I have written my own code to access the device Torch. The code WORKS - However it doesn't work while streaming the webcamtexture (the camera is in use so the java service call returns an error). Does anyone have any suggestions for how to get around this issue? Is there any way to use Unity's WebCamTexture to activate the camera torch? Here is my code for activating the camera torch:
AndroidJavaClass cameraClass = new AndroidJavaClass("android.hardware.Camera");
// This is an ugly hack to make Unity
// generate Camera permisions
WebCamDevice[] devices = WebCamTexture.devices;
int camID = 0;
camera = cameraClass.CallStatic<AndroidJavaObject>("open", camID);
// I'm pretty sure camera will never be null at this point
// It will either be a valid object or Camera.open would throw an exception
if (camera != null)
{
AndroidJavaObject cameraParameters = camera.Call<AndroidJavaObject>("getParameters");
cameraParameters.Call("setFlashMode","torch");
camera.Call("setParameters",cameraParameters);
Active = true;
}
Try checking out camera capture kit for unity. It gives that functionality you want for Android as well as the source code for it.
https://www.assetstore.unity3d.com/en/#!/content/56673
i am developing a windows phone app where application has an option to pin the application to home screen. And i am using ShellTileSchedule class to do schedule the update periodically. Some reason my app is not pushing any update to tile. My app data is completely local, no data is coming from outside.
In my tile update, i am not updating any image on the lile, but only changing the data to display.
foreach (ShellTile tile in ShellTile.ActiveTiles)
{
IconicTileData tileData = GetTileData();
tileSchedule = new ShellTileSchedule(tile, tileData);
tileSchedule.Interval = UpdateInterval.EveryHour;
tileSchedule.Recurrence = UpdateRecurrence.Interval;
tileSchedule.Count=GetUserData();
tileSchedule.StartTime = DateTime.Now;
tileSchedule.Start();
tile.Update(tileData);
}
Any help in this regard? Or do i need to background agent to update the tile?
ShellTileSchedule can only pull images off the web, not from the phone itself. This is one of the limitations of ShellTileSchedule. If you want to set background images to resources on the phone, look at using push notifications instead.
Source: http://www.silverlightshow.net/news/WP7-Using-ShellTileSchedule-to-update-your-app-s-Live-Tile-background.aspx
Shouldn't you be setting a ShellTileSchedule.RemoteImageUri somewhere? I mean, that's kinda what ShellTileSchedule is there for, to update your tile image from a remote Uri on a regular interval... See sample of how to use this class for secondary tiles here.
You have to fill the properties of IconicTileData. In your sample you just create empty data structure and use it for the schedule, that won't work. I use it like this:
IconicTileData newTileData = new IconicTileData
{
Title = SharedResources.AppName,
Count = BatteryHelper.BateryLevel,
SmallIconImage = new Uri(#"/Assets/IconicSmall.png", UriKind.Relative),
IconImage = new Uri(#"/Assets/IconicMedium.png", UriKind.Relative),
};