samdutton / simpl

Simplest possible examples of HTML, CSS and Javascript:
https://simpl.info
Apache License 2.0
5.18k stars 1.64k forks source link

Doesn't work on Firefox #50

Closed alexandrevicenzi closed 6 years ago

alexandrevicenzi commented 9 years ago

Runnin on Firefox when I press start I get: ReferenceError: webkitRTCPeerConnection is not defined

RTCPeerConnection is currently implemented by Chrome and Opera as webkitRTCPeerConnection and by Firefox as mozRTCPeerConnection (http://www.html5rocks.com/en/tutorials/webrtc/basics/)

samdutton commented 9 years ago

Thanks for heads-up. Need to implement this...

wnda commented 7 years ago

Maybe I'm oversimplifying things, but wouldn't it be easy to fix this by aliasing the vendor prefixed constructors like this?

function createRTCPeerConnection(config) {
  if ('RTCPeerConnection' in window) {
    return new RTCPeerConnection(config)

  } else if ('webkitRTCPeerConnection' in window) {
    return new webkitRTCPeerConnection(config)

  } else if ('mozRTCPeerConnection' in window) {
    return new mozRTCPeerConnection(config)

  } else {
    throw new Error('Browser is not supported');
  }
}

function createRTCIceCandidate(candidate) {
  if ('RTCIceCandidate' in window) {
    return new RTCPeerConnection(candidate);

  } else if ('webkitRTCIceCandidate' in window) {
    return new webkitRTCPeerConnection(candidate);

  } else if ('mozRTCIceCandidate' in window) {
    return new mozRTCPeerConnection(candidate);

  } else {
    throw new Error('Browser is not supported');
  }
}
samdutton commented 7 years ago

Yeah — it's pretty straightforward :).

Actually the best/right way to do this is probably github.com/webrtc/adapter .

On 20 January 2017 at 18:30, A. M. Douglas notifications@github.com wrote:

Maybe I'm simplifying things, but wouldn't it be simple to simply alias the vendor prefixed constructors like this?

function createRTCPeerConnection(config) { if ('RTCPeerConnection' in window) { return new RTCPeerConnection(config)

} else if ('webkitRTCPeerConnection' in window) { return new webkitRTCPeerConnection(config)

} else if ('mozRTCPeerConnection' in window) { return new mozRTCPeerConnection(config)

} else { throw new Error('Browser is not supported'); } }

function createRTCIceCandidate(candidate) { if ('RTCIceCandidate' in window) { return new RTCPeerConnection(candidate);

} else if ('webkitRTCIceCandidate' in window) { return new webkitRTCPeerConnection(candidate);

} else if ('mozRTCIceCandidate' in window) { return new mozRTCPeerConnection(candidate);

} else { throw new Error('Browser is not supported'); } }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/samdutton/simpl/issues/50#issuecomment-274144351, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMhqn-c2dunHCmyhhKP7xe16I0sFQ_vks5rUP0ugaJpZM4Cv8gz .

bigt11 commented 7 years ago

@wnda I am looking to use this clear key code for video, but as stated above, it does not work on firefox, or IE. Any examples of the code out there for it to work on all the major browsers? This seems to only work on chrome.

hasse112 commented 6 years ago

@wnda @samdutton From where would I call the functions (createRTCPeerConnection and createRTCIceCandidate)? Would you guys mind making a basic example?

I'd really appreciate it!