Jen*_*nsB 3 javascript firefox google-chrome webrtc typescript
我无法让firefox读取blob,或者更确切地说理解包含ArrayBuffer的变量.
我正在尝试使用打字稿中的WebRTC.
// Create a data Channel for communication
this.gameChannel = this.RtcConnection.createDataChannel('g', gameDataChannelOptions);
// Start listener
this.gameChannel.onmessage = function (event: any) {
console.log(event);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码在chrome中工作,但在firefox中没有,或者说firefox无法读取结果数据(或者很可能是我做错了).
下面是chrome和FF中的控制台,注意在chrome中我看到了预期的数据,而在FF中我只是获得了预期长度的blob,但我似乎无法访问它.
如何在两个浏览器中获得相同的结果?
设置this.gameChannel.binaryType = "arraybuffer"
使其工作.
Firefox是正确的,因为"blob"
它是默认的二进制类型.试点错误.
Chrome 尚未实现 "blob"
,这可能是默认为数组缓冲区的原因.如果我"blob"
在Chrome中设置,我会得到:
Failed to set the 'binaryType' property on 'RTCDataChannel':
Blob support not implemented yet
Run Code Online (Sandbox Code Playgroud)
不幸的是,正如您的问题所示,这会导致Web兼容性问题.
归档时间: |
|
查看次数: |
125 次 |
最近记录: |