We have tried finding a good media-library for recording videos in WPF, but it seems most fall short one way or another. However, the one existing in UWP seems to be quite competent, and more in line with what we want.
I have experimented a bit, and got an UWP AppService up and running, and I was able to take a picture from WPF-application using a command. The next step was to get a video recorded, and this is where it got tricky.
I created two commands in the same BackgroundTask and kind of hoped they would be executed from the same instance so that I could store the MediaCapture-object between commands, and start the recording in one and stop it in another.
However, they seem to spawn two separate instances, so I cannot store any state between the two commands to the AppService.
Am I able to solve this problem via some configuration or another approach that would work better for my specific usecase?
I found the answer myself, if you keep the AppServiceConnection alive, it will be routed to the same instance in the AppService later on.
Related
I have been looking all over and I cannot get notifications in Unity to work without the nasty PowerShell popup needed.
My investigations
Through my investigations, I've found many ways to achieve my goals but only 1 can unsatisfactorily solve my issues. Hopefully, the community here can provide some assistance.
The first option that I found was that you can create notifications with PowerShell commands. Unfortunately, this isn't ideal as when it is ran, the PowerShell will flash on the users screen and that can be very unsettling for users. It is also very hard to customize the code as there is inadequate documentation. If you know of a way to customize PowerShell notifications and run PowerShell commands in Unity without running PowerShell then that would solve my issue,
The second option that I ran across was the Microsoft documentation for creating a toast but no matter what I try, I cannot get it to work. The closest I got was by adding a plugin folder to my assets, and adding microsoft.toolkit.uwp.notifications.7.1.2.zip\lib\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.dll to the plugins folder but then I get the error .Show() is not a command. Which meant that I can create the toast object but not display it.
Another option is to create a python script but I assume I'd encounter similar issues.
The last option that I've seen was using some 3rd party API called burned toast but I can see that I would have the issues from attempts 1 and 2 going that route.
The last option that I've seen are $60+ assets on the Unity Asset store but there is no guarantee that those will work at all or on Windows. Not to mention, spending money on what should be free is unheard of.
I'm building a C# application where 2 or more cameras are connected to a processing module that has one or more outputs. I need to be able to connect "monitor" windows to preview each camera and the processed output that can be hidden or shown independently, with additional processing filters added to the stream while the video program is running.
Conceptually, I'm trying to build something that looks like this:
(source: fkeinternet.net)
(Using the Video Mixing Filter from the Video Processing Project, I can actually build the above graph and have it run with the three video renderers displaying their respective video streams - in ActiveMovie windows, not C# form windows. Building a graph is not exactly the problem, building the complete application is the issue.)
Building on example code from the DirectShow .NET project, combined with code generated by GraphEditPlus, I can build a basic application with the video stream from a single camera displayed in a C# form window. I'm in the process of debugging multiple preview windows operating simultaneously, but I've realized there are other issues:
One of the problems with the graph illustrated above is that if any of the output windows are closed, the whole graph stops. Another is that it doesn't allow adding filters in the processing stage without stopping the whole graph and rebuilding it.
My idea is to break the monolithic graph into separate source, processing and display graphs so that each piece can be started or stopped as needed, something like this:
(source: fkeinternet.net)
I'm assuming I'd have to keep one graph running all the time to provide a "master clock" source for everything else (probably the "Processing Graph" component), but I'm not quite sure how to do that.
Is there a "standard" way for connecting multiple graphs together? For that matter, is it even possible? I've done a number of searches along the lines of "c# directshow connect two graphs" but all of the links returned are related to connecting filters together, not graphs. Am I asking the wrong question?
I stumbled across this post which pointed me to the answer I was looking for - GMFBridge
Currently im trying to make a lobby system for my game, the lobby system seems to have quite a few issues but im slowly working my way through them. I cannot however, find out a way to make the host automatically get added as a player in the game, when he starts a server. There will never be a situation where the host will only act as the server, so i need him to automatically get added to the game.
I have tried a bunch of different things with ClientScene.AddPlayer() But i cannot make this work.
Further, i cannot find any documentation on what functions the different buttons on the standard unity network lobby hud actually do, so i have a hard time replicating the behaviour.
Anyone has any good sources /ideas on the issue?
There is a method in the given NetworkManager called StartHost(). Try this for starting the server.
See the Scripting API for NetworkManager.StartHost() and all the methods from the NetworkManager
You have to write a custom UI and network manager to eliminate the Start Server GUI option which is by default provide by the Unity Networking GUI component. You can view this simple tutorial (UI & Custom Net Manager) to understand it.
For a while I've been trying to think of ways to achieve a simple task: I have two background tasks in my app, and I want one to notify the other about certain changes (only one-way communication required), but for the life of me I can't figure out any way that works. These are the methods I found from the internet, but all of them have issues:
I thought I could create a simple text file in the local folder of the app and put the notifications there. The listening process could somehow subscribe to that file and be notified of any changes in its content. This was achievable previously with the FileSystemWatcher class, but it was removed from Windows 8 onwards.
Then I found another API for implementing the above method, namely the QueryOptions class. But it turned that while it's available in Store apps, it's not supported on Windows Phone.
I thought about using push notifications, but they're all linked to a web service. As of yet I can't figure out any way to use them to send and receive notifications locally without a web server.
Is there any way to go about doing this? It seems like a very straightforward task but it's turning out to be impossible to achieve. Is there any other API on Windows Phone that allows a process to be notified when the contents of a file are changed? Or is there any way I can work around with push notifications and achieve this? I also read in places that named pipes and sockets are often used to achieve this kind of functionality on other platforms, is there any way to apply this here?
Short of polling the text file for changes every half a second or so (which would be highly inefficient and introduce lag which is something my app can't tolerate), I can't figure out any other way to achieve this task.
Thanks in advance.
If you want a general-purpose IPC mechanism across two or more processes in the same app, you can look into this sample which wraps Win32 IPC primitives.
There is no way to "wake up" a process (or start a background task) when a file changes. So this only works if the processes will be running at the same time (if they're not running at the same time, you can use some other sort of signaling mechanism, such as a placeholder file on disk).
There is also no way to signal across two different apps; you have to round-trip via the network for that (eg, one app pings a server that relays it to the other app).
I've spent almost 4 hours trying to figure out a solution for this issue. Basically, I am writing an application in C# using DirectShowNet that shows video from a webcam, allows you to take snapshots, and change resolution of the webcam. I have a device manager that detects when a webcam is unplugged, then replugged back in. However, I'm having difficultly recreating the graph after the device has been plugged back in.
The first thing I do is create the FilterGraph object and cast it to a IFilterGraph3. Then, I make this call:
graphBuilder.AddSourceFilterForMoniker(deviceMoniker, null, deviceName, out sourceFilter)
This call works when you initially launch the application, and even if you Dispose of the graph and create a new one. However, the only time is doesn't work is when trying to create the graph after the device is plugged back in.
On one machine (Win8 x64), I am receiving this error:
REGDB_E_CLASSNOTREG - 0x80040154 - Class not registered
On another machine (Win7 x64), I am receiving this error:
REGDB_E_IIDNOTREG - 0x80040155 - Interface not registered
I have tested both building this code as Any CPU and x86. Also, I have tested it on other machines, but independent of the OS, I still get the Interface not registered error. I have tried using both a Logitech C920 and a Microsoft LifeCam Studio. Both result in the same error. I have also tried the alternative, using the IMoniker method:
deviceMoniker.BindToObject(null, null, ref baseFilterId, out source);
Same error occurs. I feel like there may be something that is lingering after the device is disconnected that I am not cleaning up to allow the graph to grab the source (webcam filter) properly. Any ideas would be appreciated.
General HRESULT error codes can be found here: COM Error Codes (Generic)
So, basically, I just woke up one morning, got to work, and stared at the code and went, "Wait, I know why this isn't working...". It is a threading issue. The initial graphs I was creating were on a different thread than the graphs I was trying to create later. That's why it only happens when I recreate the graphs.
I was also having a problem with IVideoWindow's put_Owner method when the device is plugged in after the application has already started. In this case, the device wasn't unplugged while executing, and put_Owner would freeze/deadlock trying to that method.
Overall, I have a thread that is detecting when a device is unplugged/plugged in using DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice). So, when I go to create these graphs, they are not on the main UI thread where the other graphs were originally created. To solve this, I have my class that is handling the devices take in an Action<Action> invoker which allows you to provide a method wrapper. In this case, I pass it Control.Invoke of the WinForms form so that the calls on the device monitoring thread are wrapped by this invoker method within the UI thread. Completely solved my graph creation issues.
I am HIGHLY SURPRISED no one else ran into this before. I couldn't find anyone else mentioning threading when discussing issues related to this error. Very strange.