Cross Browser WebRTC DataChannel - javascript

I'm not being able to create a RTC dataChannel between Chrome and Firefox. I had success creating video and audio streams between the two browsers, but not the dataChannel.
If the communication is between two Firefox browsers or two Chrome browser, it works. Is it possible to create a dataChannel between those two?
Thanks.

Yes, it possible to create data channels between Chrome and Firefox. There's a bit of custom code required to achieve connectivity but it's not too bad.
I recommend using a module that smooths over the differences and simplifies the WebRTC API. I wrote simple-peer for this purpose. You can take a look at index.js to see where there is custom logic to handle Chrome or Firefox quirks.
Another popular solution is adapter.js (created by Google), which attempts to smooth out the differences between browsers without making the API easier to user.

Related

WebRTC Voice Activity Detection

I'm implementing a very simple WebRTC audio/video chat room using JavaScript and HTML.
It should run is all major browsers (Chrome, Firefox, Safari and Edge)
The application layout shows all the users currently collaborating, each one inside its own "square".
I would like to highlight the user that is currently speaking with a different square border color.
To the best of my knowledge the only way to implement this is using some built-in VAD API available and exposed to JS by the browser webrtc stack.
Could you please point me if this is possible, and if so, which API's should I be using ?
Code examples would be very useful.
I've never tried it, but I think you can extract the C++ code from WebRTC related to VAD and build it using WASM.

Why did Safari drop support for SharedWorker?

Why did Safari drop support for SharedWorker?
And are there any working polyfills using, for example, localStorage and StorageEvent as a communication port? (Yes, the shim would have to detect and recreate the master Worker)
Directly from one of the WebKit Engineers:
The implementation of Shared Web Workers was imposing undesirable
constraints on the engine. It never gained any adoption.
Source here
I can't find any polyfills for SharedWorker.
It seems that one can be created by implementing a StorageEvent based communication port across workers. The downside being that StorageEvents are not portable for WebWorkers, and you have to maintain state across each browser tab and know when to flick on/off each master worker.
From my understanding the answers here are correct, but it's also due to the lack of SharedWorker adoption by web developers (a chicken and egg type situation).
If you're in need of a polyfill, you can use the one I created. I couldn't find one for one of my projects, so I created this one, https://sharedworker.okikio.dev/.
Note: it doesn't handle cross tab communication, but you can use the CacheStorage API together with a ServiceWorker and MessageChannel or use IndexedDB and ServiceWorker (from #jakearchibald on Twitter) to create a similar effect
Also: I should mention that Safari is working on supporting the BroadcastChannel API, which would cover the cross tab communication aspect, it's currently available in the Webkit Technology Preview
Since safari default's behaviour on cookies is preventing third-party cookies on tracking.
If safari allows us to use SharedWorker, developer(google or tracking company) can use it to access identify between different window tab.
That's the reason why safari drop the SharedWorker, interestingly, it support WebWorker but not SharedWorker.
It's my guess, not the official reason.

Can I use javascript to record voice on a web app?

It seems I can only use Flash or Java to record voice on a web app. Is there a way of doing it via JavaScript?
It can be done but the solution won't work across all platforms at the moment.
<input type="file" accept="audio/*;capture=microphone">
See HTML5 Media Capture
Currently Supported By:
Android 3.0 browser, Chrome for Android (0.16), Firefox Mobile 10.0, iOS6 Safari and Chrome (partial support)
Links:
http://www.html5rocks.com/en/tutorials/getusermedia/intro/
Audio capturing with HTML5
Javascript cannot access your hardware directly. What you need, is a client side technology that can. Flash, for one.
Javascript can communicate quite easily with flash, so you can hide your flash recorder and construct your recorder ui with html/js/css.
Here's one example: https://github.com/jwagener/recorder.js/blob/master/examples/example-1.html
Here's another one:
http://blogupstairs.com/flashwavrecorder-javascript-flash-audio-recorder/
I realize this is not EXACTLY what you need, but you didn't tell why you want a JS solution. This doesn't fix the flash dependency problem but it solves the UI problem since you can construct the UI without flash.
Another wellknow solution is WAMI, I know it's not pure javascript but maybe it can help.
"As of this writing, most browsers still do not support WebRTC's getUserMedia(), which promises to give web developers microphone access via Javascript. This project achieves the next best thing for browsers that support Flash. Using the WAMI recorder, you can collect audio on your server without installing any proprietary media server software."
https://code.google.com/p/wami-recorder/
Another example using node.js
This example application is written in JavaScript and uses Node and Express for the web server and framework. You will need all three installed on your web server in order for this to work, as well as the Node.js WebAPI Library.
nodejs voice recording example
Yes there is a pure HTML/JavaScript way but it only works in Firefox and Chrome:
http://audior.ec/blog/recording-mp3-using-only-html5-and-javascript-recordmp3-js/
Direct demo: http://audior.ec/recordmp3js/

how to Run Websocket in IE

I have a website where i am using websocket i have to run my website on IE also but IE does not support websocket is there any way to run the websocket on IE?
IE Versions < 10 do not support Websockets, but you can use alternative techniques like flash or ajax-longpolling.
I recommend you to use a Framework so you don't have to take care of all the cross browser issues. A very good framework for this is socket.io
Edit 2017: this should probably not be an issue anymore, since websockets are now basically supported across the board.
You can download the webpage source code that runs in Chrome, Firefox, and IE (at least) via the blog article "Websocket Server Demonstration" from the High Level Logic Project. The webpage is set up for developers.
Make sure you also click and read "(UPDATE: Demo on MSIE)" linke in the article. Following the simple instructions will load the google plugin that will allow you to run up-to-date websockets in IE.

Is there any way to run a server or peer-to-peer from a browser?

The title basically says it all. I'm aware this can't be done using traditional means. I'm not aware of any way to do it using Web Sockets, though I've never built anything more than toy apps with them.
It is fine if the solution is browser-specific (even on the client-side; i.e. peer-to-peer communication would also be awesome). For instance, is there any way to accomplish this using Chrome's NaCl?
Furthermore, if this isn't possible now, is there any fleshed-out specification for how it will work in the future? For instance, Chromium-based browsers are experimenting with a "P2P Javascript API" which appears to be currently entirely undocumented.
Here's the HTML5 spec on it:
http://www.whatwg.org/specs/web-apps/current-work/multipage/video-conferencing-and-peer-to-peer-communication.html#peer-to-peer-connections, though its status is unclear.
Sorry if this question is a bit haphazard; I'm basically interested in the current status of all in-browser APIs that could be used for p2p communication.
Edit: I'm not interested in Flash p2p. I'm aware it can be done, and is definitely a solution to current p2p problems, however I'm interested in new technology.
Update May 2012: For those still looking at this, the peerconnection API is slowly making its way into browsers. It is now experimentally in Chrome, along with the rest of the WebRTC API. You can check out the documentation and spec here.
There's Opera Unite but I'm not aware of any cross-browser standardization effort based on that. I think by default it proxies through Opera's servers for DNS, but you can set it up for direct connections.

Categories