How to select camera in webapp? - html

How to choose between the front and rear camera in a webapp?
also usefull for: How to choose between multiple microphones?

There is a live example on:
https://webrtc.github.io/samples/src/content/devices/input-output/
(This webrtc-link is new, and should work on Chrome mobile)
Link is from this answer - https://stackoverflow.com/a/35480435/2414207, which is discussing MediaDevices.enumerateDevices()[new] vs MediaStreamTrack.getSources()[deprecated] in depth.
You can find further information (slightly outdated now, but usefull to get the big picture) about this on:
http://www.html5rocks.com/en/tutorials/getusermedia/intro/#toc-gettingstarted
Scroll down and skip:
Feature detection
Gaining access to an input device
Setting media constraints
until
Selecting a media source
For reference: my former live example (broken)
https://simpl.info/getusermedia/sources/
They are using MediaStreamTrack.getSources()[deprecated],this is not working on Chrome 45 and Firefox 39 anymore.
For the new function MediaDevices.enumerateDevices() - see https://stackoverflow.com/a/35480435/2414207

Related

mxClient renders different shapes all as squares

Several weeks ago I have been asked to upgrade a web application based on a very old version of MXGraph library (version 2.4). The application integrated also the 'grapheditor' a sort of demo application evolved later in Diagramly
and then in Draw.io). Recently I completed the more problematic step, the transition from old "grapheditor" to Draw.io, so I am now able to open all the previous diagrams (saved as plain XML), modify and save them consistently.
Ok, this is the nice part. The bad side is the 'read-only' section of the application ,where the users can more or less, only view the graph.
This page is based on the mxClient.js that renders the graph described in the xml through this code:
var graph = new mxGraph(container);
var diagram = mxUtils.parseXml(xml);
var codec = new mxCodec(diagram);
codec.decode(diagram.documentElement, graph.getModel());
graph.fit();
Upgrading the MX library to the last version (3.9.10) the same code works but some shapes are not rendered properly, they appears as squares instead of
circles, ellipses, etc. The two following images are an example of this misbehavior
Graph in the draw.io:
Same graph rendered by mxClient:
After some tries I discovered that the old mxClient is able to render the same graph perfectly (as draw.io does) so I think there have to be something wrong (or missing) in my code or mxGraph installation/configuration.
As a temporary workaround I can keep in place the old version of mxGraph but obviously I'd like to use the new one.
Can someone give me an hint on this? Any help would be very appreciated.
The tape shape isn't part of core mxGraph, it's part of the GraphEditor example, in the additional shapes JavaScript.
If you look at the style of the ellipse, it's probably not the one in the core, most likely another one from Shapes.js.
Either pull in shapes.js, or use the viewer in draw.io.

Forge Viewer select element by tapping screen not working correctly on Surface Pro using IE 11 (via cordova)

Using Surface pro touch screen to select element in viewer works sometimes other times it seems to translate to a rotate/zoom action. In this case the viewer rotates/moves and the element is NOT selected.
When logging the events there are plenty of mouse down/up events along with mouse moves when it doesnt work. When select does work a single click event occurs.
Double click seems to work ok.
Zoom/rotate etc using standard tools works ok.
Using the keyboard cover touch pad that you can get for the Surface pro to move and click works as expected and the element is selected.
Running same application on a GETAC Windows 10 ruggadised tablet the select element works correctly so it seems related to the Surface Pro.
Unable to change browsers as cordova apps use IE11 on windows and that is currently fixed.
The only solution i can think of for the moment is to remove the standard navigation tools completely (somehow) and recreate a select mode tool that would ignore any mouse moves and use button down event to select element.
Any suggestions on how to fix this?
Tech Details:
Windows 10 Pro,
Surface Pro,
Browser: IE11,
Viewer version 2.11,
Other: WINJS81 cordova application
Thanks for any help
We've had problems with touch events on the Surface Pro in the past. It sounds like the edges of the touch screen are overly sensitive and are triggering extra touch points.
Does the problem happen if you are holding the device up, gripping with one hand, and using your other hand to touch/select a 3D object ?
Could you try doing a selection again, but this time, make sure you other hand is not holding the edge of the screen? (Perhaps place the device on the surface of a desk, so you are not holding it up)
Found a fix to this issue. In viewer3D in the base toolcontroller there is line
var kClickThreshold = 2;
This value is used further down in code to determine if singleClick has occured. It does it by comparing XY on down and up events.
var deltaX = _downX - event.canvasX;
var deltaY = _downY - event.canvasY;
_downX = -1;
_downY = -1;
if( Math.abs(deltaX) <= kClickThreshold && Math.abs(deltaY) <= kClickThreshold )
_this.handleSingleClick( event );
If movement is above this threshold it does not trigger singleClick if below it does.
Did testing and increasing the value to around 5-7 means that the selection of elements worked consistently. (there is still a minor rotate or zoom at same time as select occurs but I assume that this would be another part of viewer that would need adjusting)
Unfortunately it does require edit of viewer code but easy enough. I added code to overwrite standard value if external variable existed.
Would be nice for future viewer dev if more of these types of properties be exposed so that direct edit of code is not required.
Still it is good to have the source code to be able to debug at this level.
At a guess the Surface Pro 4 must have a more sensitive touch system or it could just be related to IE11 as well.

three js crushing on chrome android

Im trying to open this link http://3dhd.co.il/mobile/170 in my chrome browser in samsung galaxy s6, and after about 2 minutes the browser crushes and im getting the message "Rats Web GL hit a snag".
I've tried following the chrome instruction (clear cookies etc), tried enabling the flags in chrome://flags.
How can i debug this problem and understand why is it happening,
i developed that scene, and i cant understand what i have done wrong.
Thanks.
Here's Suggestion .
Overlap vertices example :
It means that 3d mesh object is complex . Try to use blender ( free software ) open 3d object (import) click to enter edit mode . Then you can see numbers of vertex point. Best optimization for this example is to make convex optimise .
Also check materials !
See this answer :
Three.js project crashes mobile
Look at :
https://blender.stackexchange.com/questions/6253/how-to-convert-from-high-poly-to-low-poly

Soft vibration, in an app

Okay I'm developing a win phone app, and I have buttons here and there and I want the phone to vibrate when someone hits a button.
I managed to do that with
using Windows.Phone.devices.Notification;
VibrationDevice v = VibrationDevice.GetDefault();
v.Vibrate(TimeSpan.FromSeconds(0.1);
However that vibration is rather strong and annoying to get everytime someone hits a button, I'm wondering, do we get access to the soft vibration? Like when someone hits the windows button / back key / search glass - those three buttons have a more soft vibration
For WP7.1 you could use XNA:
Microsoft.Xna.Framework.WindowsPhone.Input.GamePad.SetVibration(player, leftMotorStrength, rightMotorStrength)
However, for Windows Phone 8 this is not possible.
Please refer to MSDN for more details.
You can use a shorter timespan. Do some experiments on different devices. You might need to use different values for different devices.
I got a really nice soft vibration from Samsung ATIV Odyssey with TimeSpan.FromSeconds(0.01). However, HTC 8X seems to ignore a timespan this short - the results with 0.02 was somewhat inconsistent; 0.03 was a good one.

Pinch to zoom independent axes in 4.0 ice cream sandwich

I developed a mobile app inside Adobe Flex (4.6) and it includes using pinch-to-zoom functionality to zoom in on pictures to make it easier to read words in the pictures. In previous android versions (2.1 to 2.3.3 and 2.3.4 if you're running cyanogenmod) the pinch-to-zoom works fine. But if the app is run on an ICS (Android 4.x) device, the axes seem to handle the enlargement of the picture individually. i.e. when you move your fingers apart horizontally, the image gets very wide, but stays the same vertical size, and vice versa.
First, does anyone know why this is happening?
And second, does anyone know of a way to fix it to work as it did before?
I will update to include screenshots.
Update: I have confirmed this is also an issue with Honeycomb. i.e., 3.x OS acts the same as 4.x ICS.
Sense, running the latest HTC update:
ICS, on AOKP, but verified this is an issue with standard ICS distros as well:
Solved this. Code was previously:
protected function onZoom(e:TransformGestureEvent, img:Image):void
{
DynamicRegistration.scale(img, new Point(e.localX, e.localY), img.scaleX*e.scaleX, img.scaleY*e.scaleY);
}
change the final e.scaleY to e.scaleX. This makes it scale based on only one portion of the zoom (in the x direction) and scales both X and Y accordingly. Not exactly perfect, but it works very well in practice.
Final code is this:
protected function onZoom(e:TransformGestureEvent, img:Image):void
{
DynamicRegistration.scale(img, new Point(e.localX, e.localY), img.scaleX*e.scaleX, img.scaleY*e.scaleX);
}