WebRTCを初期化するために私の方法でSafari Tech Preview 11で未処理のプロミス拒否を取得しています。具体的には、ビデオ要素にMediaStream
を割り当てたときに発生します。video.srcObject = event.stream;
- スタックトレースは、この行が例外をスローしたことを示しています。私は例外をキャッチできませんでしたtry/catch.
MediaStream未処理プロミス拒否:[オブジェクトDOMError](Safari 11)
例外はSafari 11でのみ発生します(Chromeでは発生しません)。この場合に役立ちます
initWebRTC(p){
var self = this;
return new Promise((resolve, reject) => {
self.state.connection = new RTCMultiConnection();
self.state.connection.socketMessageEvent = 'webrtc-firebase';
self.state.connection.setCustomSocketHandler(FirebaseConnection);
self.state.connection.firebase = 'webrtc-firebase';
self.state.connection.enableFileSharing = true;
self.state.connection.session = {
audio: true,
video: true,
data: true
};
self.state.connection.sdpConstraints.mandatory = {
OfferToReceiveAudio: true,
OfferToReceiveVideo: true
};
self.state.connection.onstream = function(event) {
console.log('event.mediaElement',event.mediaElement);
console.log('event.stream',event.stream);
var videoContainer = document.getElementById('videoContainer');
var video = event.mediaElement;
if (!window.safari){
var source = document.createElement("source");
source.srcObject = event.stream;
video.appendChild(source);
} else { // Safari
try{
video.srcObject = event.stream; // this is the line that throws the exception
}catch(e){ //unable to catch the exception
console.log('exception',e);
}
}
videoContainer.appendChild(video);
var playPromise = video.play();
if (playPromise !== undefined) { // not a Promise in some browsers
playPromise.catch(function(error) {
});
}
setTimeout(function() {
var playPromise = video.play();
if (playPromise !== undefined) {
playPromise.catch(function(error) {
});
}
}, 5000);
};
resolve();
});
}
わからないが、ここではトレースです:ここで
はメソッドである任意の助けをいただければ幸いです[Error] Unhandled Promise Rejection: [object DOMError]
(anonymous function)
rejectPromise
onstream (index.js:5787) // this is the video.srcObject = event.stream; line
(anonymous function) (RTCMultiConnection.js:4092)
getRMCMediaElement (RTCMultiConnection.js:1113)
onGettingLocalMedia (RTCMultiConnection.js:4064)
onGettingLocalMedia (RTCMultiConnection.js:4984)
streaming (RTCMultiConnection.js:3289)
(anonymous function) (RTCMultiConnection.js:3358)
promiseReactionJob
。ありがとう!
ありがとうございます。それは働いている。しかし、まだエラーがあります:) –