暂停视频时,最后一帧显示在元素中,如何清除元素以清除帧,并显示元素的初始背景样式?
答案 0 :(得分:0)
var vid = document.getElementById("myVideo");
vid.onpause = function() {
// change background color of element or add overlay to the element
};
答案 1 :(得分:0)
我通过查看示例代码得到了答案。关键是通过connection.close()停止传输,这样就不会有来自发送方的新blob,并将接收方视频的src设置为空字符串。
var connection = new RTCPeerConnection({ iceServers: _iceServers });
...
// Close the connection between myself and the given partner
_closeConnection = function () {
if (_connection) {
_onStreamRemovedCallback(null, null);
// Close the connection
_connection.close();
}
},
onStreamRemoved: function (connection, streamId) {
// todo: proper stream removal. right now we are only set up for one-on-one which is why this works.
console.log('removing remote stream from partner window');
// Clear out the partner window
var otherVideo = document.querySelector('.video.partner');
otherVideo.src = '';
}