How to send native texture ptr from Unity web player to a browser plug-in? - browser

I have written an NPAPI browser plug-in (using Firebreath) that Unity uses
to access a Kinect camera. I can retrieve skeleton data from Unity through JavaScript easily since it isn't too big, but the problem is in retrieving color image data.
Is it possible to send a native texture pointer (GetNativeTexturePtr)
from Unity through JavaScript into the C++ plug-in so that it can write the texture data directly? (tested in standalone version and it works)
Any other suggestions on how to transfer image data from browser plug-ins to Unity web player are very welcome.

Unfortunately NPAPI plugins do not contain any mechanisms for exchanging binary data with the page. Probably the most performant way of doing that that I know of would be to base64 encode it and send it as part of a string.
Note that strings in NPAPI are UTF8.
The only way to get anything from Unity in your plugin would be to use the javascript interface, so you can use whatever methods you can find and then pass the data into your plugin; however, note that Unity is most likely running in another process, so you probably can't use any direct memory pointers that you might get from it.

Related

PWA InkCanvas save strokes as svg in javascript

I need to use InkCanvas in my web application using javascript (angular), is it possible to save InkCanvas as a SVG using javascript (or convert InCanvas to canvas)? i see this, but it seems it works for C#, i need a way to do it in javascript!
I think InkCanvas is only supported in Universal Windows Platform (UWP) for Windows10. This is confirmed in this SO post.
You can use Webassembly to run C# code in web browser using some JS helpers. Here is a post explaining the same.
You can try this with the c# code that you are interested in. Compatibility depended. These are relatively new features and only way to know is to try.

Node.js - PDF, DOC, DOCX to PNG

Is there any library that can parse and generate a PNG from a Doc, Docx and PDF file?
We're implementing a training system using Node, Sails.js, Express and SQL and would like to generate some PNG image tiles for training modules based on a file upload.
I've done some searching and found some libraries in C# that can do all 3, as well as a just PDF impementation for Node but can't find anything that does more than that.
A point towards any 3rd party libraries or standard implementations of this method would be great.
Thanks
You can do that sort of stuff with C# (probably only on Windows) because C# is from MS stables, the same stable that churns out doc and docx. I am not sure whether the same implementation would work on Linux or Mac (even with Mono).
If you want to achieve this in NodeJS, just create the app in C#, wrap it in a ReSTful cover and call this ReSTful service in NodeJS (via Kue or something similar).
Honestly, converting file formats is a compute intensive process process. I wouldn't recommend it doing it the same main thread any way. If you're anyway gonna spawn a worker, you might as well do it in C# where it's perhaps faster.
Not necessarily an exact match for your requirement, but since you mentioned training purpose, I would recommend Watson Developer Cloud - it has document conversion among many other features which may be relevant and useful for your objective as a whole.
Speaking of the current problem, please see Document conversion overview to see how we can convert a PDF into a desired format such as HTML. Then you could actually get the PNG files from the HTML resource bundle.
Hope this helps.

How to record audio in a Chrome Extension?

What's the simplest way to setup a chrome extension to record audio from the microphone?
I see there is a working experimental speech input API but how come you don't have access to the recorded file? Seems like hooking up into that should be simple enough, as it's a step earlier in the process, no? Especially as there is also a text-to-speech API, so you could effectively record into text and then have the computer speak it back out, but unless you want a standard voice, how lame, redundant and prone to error is that?
Then there seem to be flash solutions like this but how can I use that in a chrome extension without having to setup anything server-side? (since I don't actually need to send anything to a server--it's all local and client-side)
Is NPAPI a possibility? Is there such a plugin ready-made?
Don't know of other possible alternatives (HTML5 isn't ready yet, it seems) but I welcome anything functional and simple to implement and hook into a chrome extension.
Finally a native solution appeared: Introducing getUserMedia
You cannot use the speech input API, since it will record only the microphone. Okay, you can grab the speakers like that, but it's clearly not the solution.
Using a NPAPI plugin is a solution. You'll can identify the sound made by a particular tab and after record that source, but it is no longer web dev.

Is it possible to modify code generated by PhoneGap and how would this effect apps market application process?

Is it possible to modify/supplement code generated by PhoneGap to modify/add functionality? And how does this effect the application's likelihood of being accepted into the apps market?
The reason I am asking is because there are certain components of the desired iPhone application that we would like to have that we can not achieve with our converted CakePHP web application. These desired items include QR code scanning and augmented reality.
Yes, you can do that.
https://github.com/phonegap/phonegap-plugins
You can look there for already written (and validated) plugins.
If I remember correctly, a qrscanner plugin already exists.
Augmented reality it not really possible with phonegap. (At least not as far as I know) As you can't manipulate the camera view with phonegap.
Maby if you would write a plugin for it. But that would mean writing almost the whole application in objective-C.

Running C# app inside browser as a plugin

I have a small 2D game engine written in C#, using DirectX. Is it possible to somehow run it in a browser as a plugin? Like for example Flash and others, where you go to a site with a game and it will ask you to install a certain plugin and then you can play the game in the browser, with mouse and keyboard input.
I have searched around for hours and I still don't know what I'm looking for. I have so far primarily focused on Internet Explorer, but there are plugins, addons, extensions, etc I don't know what I need really.
Yes I think it is possible.
For example, I have an HTML page which includes an element like this:
<object id="simpleControl1"
classid="http:RenderTextProject5.dll#RenderTextProject.ScrollableControl"
height="300"
width="300">
</object>
The 'classid' attribute value has the following meaning/syntax:
RenderTextProject5.dll is the filename of a compiled .NET assembly
RenderTextProject.ScrollableControl is the qualified name (namespace plus classname) of a class which subclasses System.Windows.Forms.Control
I can then see the control being rendered in the browser.
I'm using IE (IE8, but it used to work with IE6 too), and I have the .NET framework installed on my machine (but I think I needn't have the RenderTextProject5 assembly installed on the client machine).
There may be some other caveats too (e.g. I needed to run in the Intranet security zone).
See Return of the Rich Client: Code Access Security and Distribution Features in .NET Enhance Client-Side Apps.
Look for Silverlight.. It is maybe not exactly what you need but it is a browser plugin capable of running C# code ;)
There is a relatively new plugin called Unity. It is a bit more complex, as it is a dev/3D authoring environment on its own, but uses C# as its language as far as I know. However I don't know if pure 2D programming is possible (well, may be worked around using ortho 3d?).
The basic version is free to download recently, maybe worth a check.
It is possible to run C# applications in a web browser without using plugins. For example, C# applications can be compiled into JavaScript applications using JSIL.

Resources