HTML5新特性之WebRTC详解


当前第2页 返回上一页

RTCPeerConnection带有浏览器前缀,Chrome浏览器中为webkitRTCPeerConnection,Firefox浏览器中为mozRTCPeerConnection。Google维护一个函数库adapter.js,用来抽像掉浏览器之间的差异。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

var dataChannelOptions = {

  ordered: false, // do not guarantee order

  maxRetransmitTime: 3000, // in milliseconds};

  var peerConnection = new RTCPeerConnection();

  // Establish your peer connection using your signaling channel herevar dataChannel =

  peerConnection.createDataChannel("myLabel", dataChannelOptions);

 

dataChannel.onerror = function (error) {

  console.log("Data Channel Error:", error);

};

 

dataChannel.onmessage = function (event) {

  console.log("Got Data Channel Message:", event.data);

};

 

dataChannel.onopen = function () {

  dataChannel.send("Hello World!");

};

 

dataChannel.onclose = function () {

  console.log("The Data Channel is Closed");

};

4、参考链接

[1] Andi Smith, Get Started with WebRTC

[2] Thibault Imbert, From microphone to .WAV with: getUserMedia and Web Audio

[3] Ian Devlin, Using the getUserMedia API with the HTML5 video and canvas elements

[4] Eric Bidelman, Capturing Audio & Video in HTML5

[5] Sam Dutton, Getting Started with WebRTC

[6] Dan Ristic, WebRTC data channels

[7] Ruanyf, WebRTC

以上就是HTML5新特性之WebRTC详解的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

HTML5百叶窗效果的示例代码_HTML5教程技巧

如何在网站头部添加视频海报?添加视频海报的方法(代码示例)

HTML5 source type有什么用处?HTML5 source标签的详细介绍

h5的语义化标签新特性应该如何使用

electron页内查找模块介绍(代码示例)

关于h5中背景音乐的自动播放效果的实现

(server-sent events)浅谈h5 中的服务器推送事件

HTML5实现图片的3d旋转效果

element-ui对话框可拖拽的功能如何实现?(附代码)

用h5的canvas做出弹幕效果

更多相关阅读请进入《HTML5》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...