
2. Updated test pages to use adapter.js Review URL: https://webrtc-codereview.appspot.com/1142004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3614 4adac7df-926f-26a2-2b94-8c16560cd09d
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
var RTCPeerConnection = null;
|
|
var getUserMedia = null;
|
|
var attachMediaStream = null;
|
|
|
|
if (navigator.mozGetUserMedia) {
|
|
console.log("This appears to be Firefox");
|
|
|
|
// The RTCPeerConnection object.
|
|
RTCPeerConnection = mozRTCPeerConnection;
|
|
|
|
// Get UserMedia (only difference is the prefix).
|
|
// Code from Adam Barth.
|
|
getUserMedia = navigator.mozGetUserMedia.bind(navigator);
|
|
|
|
// Attach a media stream to an element.
|
|
attachMediaStream = function(element, stream) {
|
|
console.log("Attaching media stream");
|
|
element.mozSrcObject = stream;
|
|
element.play();
|
|
};
|
|
} else if (navigator.webkitGetUserMedia) {
|
|
console.log("This appears to be Chrome");
|
|
|
|
// The RTCPeerConnection object.
|
|
RTCPeerConnection = webkitRTCPeerConnection;
|
|
|
|
// Get UserMedia (only difference is the prefix).
|
|
// Code from Adam Barth.
|
|
getUserMedia = navigator.webkitGetUserMedia.bind(navigator);
|
|
|
|
// Attach a media stream to an element.
|
|
attachMediaStream = function(element, stream) {
|
|
element.src = webkitURL.createObjectURL(stream);
|
|
};
|
|
|
|
// The representation of tracks in a stream is changed in M26.
|
|
// Unify them for earlier Chrome versions in the coexisting period.
|
|
if (!webkitMediaStream.prototype.getVideoTracks) {
|
|
webkitMediaStream.prototype.getVideoTracks = function() {
|
|
return this.videoTracks;
|
|
}
|
|
}
|
|
|
|
if (!webkitMediaStream.prototype.getAudioTracks) {
|
|
webkitMediaStream.prototype.getAudioTracks = function() {
|
|
return this.audioTracks;
|
|
}
|
|
}
|
|
} else {
|
|
console.log("Browser does not appear to be WebRTC-capable");
|
|
}
|