Monday, June 3, 2024
130
rated 0 times [  136] [ 6]  / answers: 1 / hits: 82157  / 10 Years ago, sun, january 25, 2015, 12:00:00

I'm developing a Chrome Extension that uses the background page to access the user's webcam.



Users are given the option to turn the camera off.



The stream appears to be being turned off. The relevant functions are no longer receiving the stream. However the webcam light (currently being developed and tested on a mac book pro) does not turn off.



Any ideas?



Here's my code for setting up the stream:



if (navigator.webkitGetUserMedia!=null) {

var options = {
video:true,
audio:false
};
navigator.webkitGetUserMedia(options,
function(stream) {
vid.src = window.webkitURL.createObjectURL(stream);
localstream = stream;
vid.play();
console.log(streaming);
},
function(e) {
console.log(background error : + e);
});
}


And here's my method for turning off the stream:



function vidOff() {
clearInterval(theDrawLoop);
ExtensionData.vidStatus = 'off';
vid.pause();
vid.src = ;
localstream.stop();
DB_save();
console.log(Vid off);
}


Any obvious I'm missing?


More From » google-chrome-extension

 Answers
35

The code above works - as shown by @jib here using the above code:



function vidOff() {
vid.pause();
vid.src = ;
localstream.stop();
}


The problem is to do with it being a persistent background page. I'm swapping over to event pages for the Chrome extension as a work around.


[#68090] Friday, January 23, 2015, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
davonte

Total Points: 581
Total Questions: 101
Total Answers: 113

Location: Sudan
Member since Tue, Aug 3, 2021
3 Years ago
;