How to stop a stream

3,501 views
Skip to first unread message

Joost

unread,
Apr 9, 2012, 9:25:53 AM4/9/12
to discuss-webrtc
Is there any way to stop a local video stream? After I call
"navigator.webkitGetUserMedia" and set my HTML video element's url to
"webkitURL.createObjectURL(stream)" my webcam light comes on and the
video is displayed correctly. But I have not been able to turn the
stream off and disengage the webcam. Basically the webcam stays
activated until I close the Chrome window... Any ideas?

Thanks,

Joost

Henrik Andreasson

unread,
Apr 10, 2012, 2:56:02 AM4/10/12
to discuss...@googlegroups.com
Thanks for the feedback Joost. This is a known issue and we are working on a solution.
See crbug.com/121088 for more details.

Gaurav

unread,
Apr 12, 2012, 5:20:24 AM4/12/12
to discuss...@googlegroups.com
Hi,

Any updates on this?.... Is this issue fixed?

Thanks.

Per

unread,
Apr 12, 2012, 5:37:41 AM4/12/12
to discuss...@googlegroups.com
The bug have been fixed.
But the JS method LocalMediaStream::Stop have not yet been implemented.

Ie, You can not stop the camera in your JS. But if you navigate to another page, or refresh the page the camera should stop. 

/Per

Per

unread,
Apr 12, 2012, 5:40:00 AM4/12/12
to discuss...@googlegroups.com
The bug have been fixed but the js method LocalMediaStream::Stop have not yet been implemented.
Ie, the camera should stop if you refresh the page or navigate to another page.



On Thursday, April 12, 2012 11:20:24 AM UTC+2, Gaurav wrote:

Eric Thomas

unread,
Apr 12, 2012, 9:32:53 AM4/12/12
to discuss...@googlegroups.com
Hi,

I am doing video chat using webrtc code, my goal is to stop the videos stream from both the side, when i click on hangup button.
I used your suggestion of refreshing the window and navigating the page to another link, but it still does not work, it hang the remote browser when i click on hang up button

I am attaching the code, if possible please check why browser hangs on the other side when i click on hangup button.

OS: Win 7
Chrome:20.0.1097.0 canary

Thanks,
Eric
peerconnection_server.zip
webrtc_test.html

Joshua Fallon

unread,
Apr 21, 2012, 12:48:15 PM4/21/12
to discuss...@googlegroups.com
Hi Joost,
I'm pretty new to all of this (javascript especially, aka copy/paste and reverse engineering is my friend), my background is VoIP, I have found this as a way to turn off the camera - It works on my MacBook running Canary Version 20.0.1111.1 canary.

Hope it helps :)
Josh

<!Doctype html>
<html>
    <head>
<title>index</title>
    </head>
    <body>
    <input type="button" value="Start" onclick="showVideo()" id="showVideo">
    <input type="button" value="Stop" onclick="stopVideo()" id="stopVideo">
        <video id="video" autoplay>No video</video>
        <script>
   showVideo = function() 
    {
       navigator.webkitGetUserMedia("video", 
        function(stream) 
        {
       var video = document.getElementById("video");
       video.src = window.webkitURL.createObjectURL(stream);
    }
       );
    }


stopVideo = function() 
    {
       navigator.webkitGetUserMedia("video", 
        function(stream) 
        {
       var video = document.getElementById("video");
       video.src = window.webkitURL.createObjectURL(null);
    }
       );
    }
        </script>
    </body>
</html>
Reply all
Reply to author
Forward
0 new messages