我正在尝试通过socket.io将视频文件流式传输到我的客户端(目前使用Chrome作为客户端)。 我只获得视频的第一帧,然后出现了无法附加缓冲区:
无法执行' appendBuffer' on' SourceBuffer':The HTMLMediaElement.error属性不为空
JS代码的一部分:
if (buffer.updating || queue.length > 0) {
console.log("buffer.updating = " + buffer.updating + " queue.length = " + (queue.length));
queue.push(videoData);
} else {
console.log("else buffer.updating = " + buffer.updating + " queue.length = " + (queue.length));
buffer.appendBuffer(videoData);
}
}
};
var play = function() {
//var mimeType = `video/mp4;codecs="${$scope.codec}"`;
var mimeType = 'video/mp4;codecs="' + codec +'"';
console.log("mimetype = " + mimeType + " is supported = " + MediaSource.isTypeSupported(mimeType));
buffer = mediaSource.addSourceBuffer(mimeType);
buffer.addEventListener('update', function () {
if (queue.length > 0 && !buffer.updating) {
console.log("buffer.appendBuffer");
buffer.appendBuffer(queue.shift());
}
});
video.play();
};
请帮帮我!