Firefox不了解Chrome确实知道变量包含ArrayBuffer [英] Firefox not understanding that a variable contains an ArrayBuffer while Chrome does

查看:94
本文介绍了Firefox不了解Chrome确实知道变量包含ArrayBuffer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使Firefox读取blob,或者更确切地理解包含ArrayBuffer的变量.

I have trouble making firefox read a blob, or rather understand a variable contains an ArrayBuffer.

我正在用打字稿尝试WebRTC.

I am experimenting with WebRTC in typescript.

// Create a data Channel for communication
this.gameChannel = this.RtcConnection.createDataChannel('g', gameDataChannelOptions);
// Start listener
this.gameChannel.onmessage = function (event: any) {
    console.log(event);
}

上面的代码在chrome中运行,但在Firefox中不起作用,或者说Firefox无法读取结果数据(或者很可能是我做错了).

The above code is working in chrome, but not in firefox, or rather firefox cannot read the resulting data (or most likely I'm doing something wrong).

下面是chrome和FF中的控制台,请注意,在chrome中,我看到了预期的数据,而在FF中,我只是得到了预期长度的blob,但我似乎无法访问它.

Below is the console in chrome and FF, notice that in chrome I am seeing the expected data, while in FF I just get a blob of the expected length, but I cant seem to access it.

如何在两种浏览器中获得相同的结果?

How do I get the same result in both browsers?

推荐答案

设置this.gameChannel.binaryType = "arraybuffer"使其起作用.

Firefox是正确的,因为默认值为 "blob" 二进制类型.飞行员错误.

Firefox is correct, because "blob" is the default binary type. Pilot error.

Chrome 尚未实现 "blob",这可能是为什么它默认为数组缓冲区的原因.如果我在Chrome中设置"blob",则会得到:

Chrome does not yet implement "blob", which is probably why it defaults to array buffer. If I set "blob" in Chrome I get:

Failed to set the 'binaryType' property on 'RTCDataChannel':
Blob support not implemented yet

不幸的是,正如您的问题所表明的那样,这导致了Web兼容性问题.

Unfortunately, this is causing web compatibility issues, as your question demonstrates.

这篇关于Firefox不了解Chrome确实知道变量包含ArrayBuffer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆