Has someone ever tried to use WebRTC with Elm


#1

I would like to build a video chat application that utilizes WebRTC. To stay responsive I will implement this application as a SPA.
Now, I know that Elm can handle the SPA use case well, and got even better with the 0.19 release. But I have nothing found about WebRTC yet. Has someone experience with this? Is there a blog post I did not found?


#2

AFAIK there are no Elm libraries that currently make it ‘easy’ to work with WebRTC in Elm.

However, the WebRTC JavaScript calls are already quite high-level, and you could relatively easily interact with them using some Ports.


#3

I just made an Elm app with camera, I render a normal empty video tag in Elm.
Then I inject the camera into that element in javascript.
Messages like start/screenshot ++ is handled via ports.

You can also create a custom “elm-video” element and listen to events directly in elm on that node. Without ports.

Elm code:

Html.video
  [ Html.Attributes.id "videoTag" ]  [ ]

Javascript

// CAMERA
  video = document.getElementById("videoTag");
  if (navigator.mediaDevices.getUserMedia) {
    navigator.mediaDevices
      .getUserMedia({
        video: {
          facingMode: "environment"
        }
      })
      .then(function(stream) {
        video.srcObject = stream;
        video.play();
      })
      .catch(function(error) {
        console.log("Could not open camera",error);
      });
  }

#4

I’ve been using a custom element for media capture and it works well. If I can figure out how to represent the constraints well I’ll publish soon.

A few of us were just talking about WebRTC over drinks but I’m fairly certain it hasn’t yet been attempted.


#5

I have been using WebRTC for data transfer in my soon-to-be SaaS (with ports), but it didn’t end up very reliable (probably due to the hand-written Node signaling server though).


#6

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.