I am trying to implement WebRTC using this library (RTCMulticonnection) and am encountering a Type Error
when trying to set the 'srcObject' on the video mediaElement in Safari Tech Preview 11.
Relevant code:
if (isSafari) {
//I've tried the 4 ways below to set the srcObject but all cause a Type Error
// mediaElement['srcObject'] = window.URL.createObjectURL(stream); throws type error
// mediaElement['srcObject'] = stream; throws type error
// mediaElement['src'] = window.URL.createObjectURL(stream);
// mediaElement.srcObject = stream; // throws type error
}
When I print mediaElement
, I get: <video></video>
When I print stream
, I get a MediaStream
object.
MediaStream {streamid: "722cfcc7-0687-4265-b266-e81b2abf8398", idInstance: "{\"audio\":{\"mandatory\":{},\"optional\":[{\"bandwidth\":…\":[{\"bandwidth\":4194304},{\"facingMode\":\"user\"}]}}", isVideo: 1, isAudio: false, type: "local", …}
Error
TypeError: Type error
[Error] No message (2)
TypeError: Type error — RTCMultiConnection.js:4089
Object audio: {mandatory: {}, optional: [{bandwidth: 1048576}]}
video: {mandatory: {}, optional: [{bandwidth: 4194304}, {facingMode: "user"}]}
Object Prototype
onMediaError (RTCMultiConnection.js:5215)
onLocalMediaError (RTCMultiConnection.js:806)
onLocalMediaError (RTCMultiConnection.js:4995)
(anonymous function) (RTCMultiConnection.js:3365)
promiseReactionJob
The Type Error
is caught in this then/catch
:
navigator.mediaDevices.getUserMedia(options.localMediaConstraints).then(function(stream) {
stream.streamid = stream.streamid || stream.id || getRandomString();
stream.idInstance = idInstance;
streaming(stream);
}).catch(function(error) {
options.onLocalMediaError(error, options.localMediaConstraints });