Giter VIP home page Giter VIP logo

Comments (13)

mseddon avatar mseddon commented on July 17, 2024

Aha. Since that was written, we have added the org.scalajs.dom.experimental package, as you have found- in which things like WebRTC are welcome. Personally, I would love to see WebRTC in this library, but I've not found the time to add it.

I think it seems sensible to implement IceCandidate and friends too- but they should probably sit in a org.scalajs.dom.experimental.webrtc package. getUserMedia can be pimped as in the Vibration API, as you mention. Perhaps simply through an implicit defined on the webrtc package object.

from scala-js-dom.

lihaoyi avatar lihaoyi commented on July 17, 2024

yeah putting it in experimental would make sense. Someone should go
update the readme =D =D =D

On Fri, Nov 13, 2015 at 10:56 AM, mseddon [email protected] wrote:

Aha. Since that was written, we have added the
org.scalajs.dom.experimental package, as you have found- in which things
like WebRTC are welcome. Personally, I would love to see WebRTC in this
library, but I've not found the time to add it. I think it seems sensible
to implement IceCandidate and friends too- but they should probably sit
in a org.scalajs.dom.experimental.webrtc package.


Reply to this email directly or view it on GitHub
#171 (comment)
.

from scala-js-dom.

mseddon avatar mseddon commented on July 17, 2024

@lihaoyi I just opened that file :D. Sadly it's Friday evening and I'm being dragged out as I type this. I'll PR that tomorrow unless someone else beats me to it. :)

from scala-js-dom.

coreyauger avatar coreyauger commented on July 17, 2024

Ok cool.. I will take this on :)

from scala-js-dom.

coreyauger avatar coreyauger commented on July 17, 2024

I think the first step will be to add the support described here
https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

However.. there is a commonly used "support" file that the js community uses to establish support for webrtc... seen here.
https://github.com/HenrikJoreteg/webrtcsupport/blob/master/index-browser.js
and this
https://github.com/webrtc/adapter/blob/master/adapter.js

I am wondering if we want to include such a support file in our implementation as well ?

from scala-js-dom.

coreyauger avatar coreyauger commented on July 17, 2024

OK I have a good start to things here.
https://github.com/coreyauger/scala-js-dom/blob/webrtc-api/src/main/scala/org/scalajs/dom/experimental/WebRTC.scala

If you have a seconds.. take a glance and make sure I am not going off on a major tangent here :)

Thanks !

from scala-js-dom.

mseddon avatar mseddon commented on July 17, 2024

LGTM so far! One thing I might suggest though is if it all sits in org.scalajs.dom.experimental.webrtc - there's quite a lot of classes in there that would otherwise clutter the experimental namespace. In my opinion it is probably nicer to just import experimental.webrtc._ than import experimental.{MediaStreamTrack, RTCIdentityAssertion ...}.

from scala-js-dom.

mseddon avatar mseddon commented on July 17, 2024

In regards to the WebRTC js wrappers.. that one's a little trickier. Particularly at this point in time, afaik there are no un-prefixed webrtc implementations available. Maybe it would be good to have a method on a utility object that wires up the global namespace correctly here, since otherwise it definitely won't work for anyone :). Does anyone else has any thoughts on this?

from scala-js-dom.

coreyauger avatar coreyauger commented on July 17, 2024

Agreed on the namespace.. I will change that.

I think dom patching will be a good solution to start with. I noticed in scalajs 0.6.5 they added "Pseudo-union type". There is one place that this can be used in the WebRTC arguments... and this should help a lot in the conversion of typescript files to scalajs (as typescript supports these union types) ...Clearly something that is going to aid in the development and patching of JS .. while muddying the waters of the Scala world. My point here is that perhaps there is a way to add the kind of support we require at the @JSName level ...

Something like a list of fall-back names..
ex:

@JSName(["getUserMedia","webkitGetUserMedia"])

from scala-js-dom.

mseddon avatar mseddon commented on July 17, 2024

Hmm, yes, since the addition of the experimental package, we are increasingly going to need a convenient way to manage these. We could add a helper method (untested code) like:

  def normalize(objIn: js.Any, name: String)(fallbacks: String*): Unit = {
    val obj = objIn.asInstanceOf[js.Dynamic]
    if(js.isUndefined(obj.selectDynamic(name)))
      for(fallback <- fallbacks if !js.isUndefined(obj.selectDynamic(fallback))) {
        obj.updateDynamic(name)(obj.selectDynamic(fallback))
        return
      }
  }

Which you might use like this:

      normalize(dom.navigator, "getUserMedia")("webkitGetUserMedia", "mozGetUserMedia")

You do, of course, need to call an initialize method to set up the shim (and the user must remember to do so :(), but perhaps a helper like this should be tucked away in ext or such to make this sort of thing less painful.

from scala-js-dom.

mseddon avatar mseddon commented on July 17, 2024

@sjrd @lihaoyi any thoughts on how we should standardise the approach to this sort of problem?

from scala-js-dom.

coreyauger avatar coreyauger commented on July 17, 2024

Hi, I have a mostly working prototype here.
http://turn.conversant.im:8080

By mostly I mean the DOM is working as expected... My other project which will include some nice ways to setup and signal has a few bugs still. If interested those project exists here:
https://github.com/coreyauger/scala-js-webrtc
https://github.com/coreyauger/scala-webrtc-example

I would recommend that we suggest people use the webrtc supplied adapter.js file until the dust settles a bit more with the vendor boxing match. This will allow us to call the most up to date implementation.

Please take a look again at DOM integration.. and if it looks good I will submit the PR.
https://github.com/coreyauger/scala-js-dom/tree/webrtc-api

Also note that I have left datachannel as a TOOD which I should be able to work on some time in near future.

Thanks :)

from scala-js-dom.

coreyauger avatar coreyauger commented on July 17, 2024

Hi guys. I am going to go ahead and push this down the PR channel. Thanks.

from scala-js-dom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.