New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make gum demos use adapter.js and attachMediaStream #517
Changes from 8 commits
5dcd60b
2ca6cd3
5cdf4aa
96e00d1
6f17546
ea1590c
9bf89c9
789ff83
e243b8a
2f1240b
18c07e5
d4c4808
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,23 +8,22 @@ | |
|
||
'use strict'; | ||
|
||
// variables in global scope so available to console | ||
var video = document.querySelector('video'); | ||
var constraints = { | ||
// Put variables in global scope to make them available to the browser console. | ||
var video = document.getElementById('gum-local'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: I prefer |
||
var constraints = window.constraints = { | ||
audio: false, | ||
video: true | ||
}; | ||
|
||
navigator.getUserMedia = navigator.getUserMedia || | ||
navigator.webkitGetUserMedia || navigator.mozGetUserMedia; | ||
|
||
function successCallback(stream) { | ||
window.stream = stream; // stream available to console | ||
if (window.URL) { | ||
video.src = window.URL.createObjectURL(stream); | ||
} else { | ||
video.src = stream; | ||
} | ||
var videoTracks = stream.getVideoTracks(); | ||
console.log('Got stream with constraints:', constraints); | ||
console.log('Using video device: ' + videoTracks[0].label); | ||
stream.onended = function() { | ||
console.log('Stream ended'); | ||
}; | ||
window.stream = stream; // make variable available to browser console | ||
attachMediaStream(video, stream); | ||
} | ||
|
||
function errorCallback(error) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,9 +77,6 @@ var fullHdConstraints = { | |
} | ||
}; | ||
|
||
navigator.getUserMedia = navigator.getUserMedia || | ||
navigator.webkitGetUserMedia || navigator.mozGetUserMedia; | ||
|
||
function successCallback(stream) { | ||
window.stream = stream; // stream available to console | ||
video.src = window.URL.createObjectURL(stream); | ||
|
@@ -103,7 +100,8 @@ video.onplay = function() { | |
function getMedia(constraints) { | ||
if (stream) { | ||
video.src = null; | ||
stream.stop(); | ||
stream.getAudioTracks().forEach(function(track) { track.stop(); }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. possible helper function for adapter? seems like this will be used in multiple places There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc-ing @alvestrand There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fippo, maybe create an issue in the adapter repo for that? Then bump adapter.js in a separate PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @juberti, filed https://github.com/webrtc/adapter/issues/58 for adding a helper function for stopping all tracks, all video and all audio tracks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done (for both issues) |
||
stream.getVideoTracks().forEach(function(track) { track.stop(); }); | ||
} | ||
navigator.getUserMedia(constraints, successCallback, errorCallback); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think querySelector is the recommended way of doing this (@samdutton)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you need to use
querySelector()
once, it's neater and slightly more understandable to use it for everything.getElementById()
is quicker, but that's not an issue here.Don't feel very strongly though.