auduno / headtrackr

Javascript library for headtracking via webcam and WebRTC/getUserMedia
3.69k stars 502 forks source link

htracker.stop() does not work from an eventlistener #16

Open auduno opened 11 years ago

auduno commented 11 years ago

when calling stop() on a headtracker instance from an eventlistener, an InvalidStateError is raised in Chrome:

Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.

DanielMSchmidt commented 10 years ago

May you provide a jsFiddle? I couldn't reproduce that error.

ricricucit commented 10 years ago

This is happening to me as well (trying to use headtrackr in the main Controller of an AngularJS App), but i can't find the cause of the problem...if it helps they were talking about the same error here as well: http://auduno.tumblr.com/post/25125149521/head-tracking-with-webrtc

UPDATE: i just realized that the tumbler it's from @auduno :) Any updates on this? (i'm not using htracker.stop())

auduno commented 10 years ago

I haven't really had time to look at it, unfortunately. Do you have the possibility to create an example of the bug in a dropbox or jsfiddle page?

ricricucit commented 10 years ago

Well i actually solved MY problem (which was something quite stupid).

To explain it, to those who might get the same problem:

Inside document.addEventListener("facetrackingEvent", function( event ) { i was doing: overlayContext.drawImage(stickImage,some,other,stuf,etc); Where stickImage didn't actually contain an image.

I'm sure that is not a bug of headtrackr tho.

auduno commented 10 years ago

Haha, great to hear it's not my fault :)

havenchyk commented 10 years ago

Sorry, if it's not a good place to ask, but is there way to stop getUserMedia at all from headtrackr?

auduno commented 10 years ago

If you mean stopping webcam stream, no. headtrackr.stop() merely stops the tracking, not the video. The correct way to stop a getusermedia stream is to call stop() on the mediastream, but I guess you also can call stop() or pause() on the video element.

havenchyk commented 10 years ago

@auduno, thanks for quick response. As I see, mediastream is placed deep into headtrackr.js, can I get mediastream outside headtrackr.js src to stop it? Sorry for this type of questions, headtrackr.js is too complicated for me, haven't success with it for several days.

auduno commented 10 years ago

Hmm, it seems I should have added functionality for this. As far as I can tell, it's not possible to stop the mediastream without the mediastream object, which I discard after I set it up. I'll try to add functionality for that within the next couple of days.

havenchyk commented 10 years ago

@auduno oh, thanks, it would be great! Should I create new issue for this? If you give me a tips, what need to do, I can try to male a pr

auduno commented 10 years ago

I created a new issue for it now here : https://github.com/auduno/headtrackr/issues/24

havenchyk commented 10 years ago

cool, thanks