eaas为了支持IE浏览器, 选用了Temasys WebRTC Plugin 这个插件来支持webrtc。 最近发现IE下eaas打不开了,所有log记录都正常。
加了各种log, 调试了好久,最后发现IE下插件为了支持webrtc, Temasys在attachMediaStream 方法中将video tag 转成object对象,而我们eaas中需要监听video第一帧的数据后才会把视频部分显示出来,同时清除超时timer。video tag已经没有了,loadeddata 事件自然就不会触发。所以看到的现象是所有log都正常,但是一直超时。
// from https://github.com/Temasys/AdapterJS
attachMediaStream = function (element, stream) {
if (!element || !element.parentNode) {
return;
}
var streamId;
if (stream === null) {
streamId = '';
} else {
if (typeof stream.enableSoundTracks !== 'undefined') {
stream.enableSoundTracks(true);
}
streamId = stream.id;
}
var elementId = element.id.length === 0 ? Math.random().toString(36).slice(2) : element.id;
var nodeName = element.nodeName.toLowerCase();
if (nodeName !== 'object') { // not a plugin <object> tag yet
var tag;
switch (nodeName) {
case 'audio':
tag = AdapterJS.WebRTCPlugin.TAGS.AUDIO;
break;
case 'video':
tag = AdapterJS.WebRTCPlugin.TAGS.VIDEO;
break;
default:
tag = AdapterJS.WebRTCPlugin.TAGS.NONE;
}
var frag = document.createDocumentFragment();
var temp = document.createElement('div');
var classHTML = '';
if (element.className) {
classHTML = 'class="' + element.className + '" ';
} else if (element.attributes && element.attributes['class']) {
classHTML = 'class="' + element.attributes['class'].value + '" ';
}
temp.innerHTML = '<object id="' + elementId + '" ' + classHTML +
'type="' + AdapterJS.WebRTCPlugin.pluginInfo.type + '">' +
'<param name="pluginId" value="' + elementId + '" /> ' +
'<param name="pageId" value="' + AdapterJS.WebRTCPlugin.pageId + '" /> ' +
'<param name="windowless" value="true" /> ' +
'<param name="streamId" value="' + streamId + '" /> ' +
'<param name="tag" value="' + tag + '" /> ' +
'</object>';
while (temp.firstChild) {
frag.appendChild(temp.firstChild);
}
var height = '';
var width = '';
if (element.clientWidth || element.clientHeight) {
width = element.clientWidth;
height = element.clientHeight;
}
else if (element.width || element.height) {
width = element.width;
height = element.height;
}
element.parentNode.insertBefore(frag, element);
frag = document.getElementById(elementId);
frag.width = width;
frag.height = height;
element.parentNode.removeChild(element);
} else { // already an <object> tag, just change the stream id
var children = element.children;
for (var i = 0; i !== children.length; ++i) {
if (children[i].name === 'streamId') {
children[i].value = streamId;
break;
}
}
element.setStreamId(streamId);
}
var newElement = document.getElementById(elementId);
AdapterJS.forwardEventHandlers(newElement, element, Object.getPrototypeOf(element));
return newElement;
};
网友评论