Skip to content
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

No possibility to stop mediastream opened by headtrackr.init() #24

Closed
auduno opened this issue Apr 11, 2014 · 9 comments
Closed

No possibility to stop mediastream opened by headtrackr.init() #24

auduno opened this issue Apr 11, 2014 · 9 comments

Comments

@auduno
Copy link
Owner

auduno commented Apr 11, 2014

It is not possible to close the getUserMedia mediastream opened by headtrackr on init(), since the mediastream pointer is discarded after initialization. The solution is to not discard the pointer and possibly add a method to close/stop the stream.

@ricricucit
Copy link

+1 for this.
Is it also possible to maybe add Addy Osmani's GetUserMedia shim (https://github.com/addyosmani/getUserMedia.js) ?

@auduno
Copy link
Owner Author

auduno commented Apr 11, 2014

I don't think I'll add the shim in headtrackr, but I was thinking of creating an option for providing your own videoElement "as is", i.e. without setting up getUserMedia, so you could then set up video with the getUserMedia shim first and provide the videoelement to headtrackr. I'll have to look at the complications wrt the rest of the code of doing this, though.

@ricricucit
Copy link

Fair enough. It might even be a better idea.
thanks!

@auduno
Copy link
Owner Author

auduno commented Apr 12, 2014

Alright, I've now added a function to stop the mediastream, so you can now call

htracker.stopStream()

on your instance of headtrackr to stop streaming from the webcam. You can also get the mediastream object from the htracker.stream property. I've also added the boolean parameter setupVideo to init(), so you have the possibility to use the videoElement "as is" by calling:

htracker.init(videoElement, canvasElement, false)

In the case you try to use the getUserMedia shim mentioned, and it's falling back to flash, I think you have to copy the video from the flash element onto a canvas (every 1/24 second or so) and pass that on to init() as the video element instead.

@ricricucit
Copy link

brilliant. thanks.

@auduno
Copy link
Owner Author

auduno commented Apr 15, 2014

Do you stop the headtracker (i.e. call htracker.stop() ) as well when you stop the stream? Or do you just call htracker.stopStream() ?

@auduno
Copy link
Owner Author

auduno commented Apr 15, 2014

huh, that's weird. It works for me. Do you see any error messages in console?

@auduno
Copy link
Owner Author

auduno commented Apr 16, 2014

I can't reproduce this. Could you share the code you're using or a mockup on dropbox or somewhere?

@abaziz
Copy link

abaziz commented Jul 6, 2014

@auduno this is working fine at our end now, the error in the previous message by Raees ("Cannot read property 'getTrackingObject' of undefined") was due to some issue in our code. Many thanks for adding this functionality.

@auduno auduno closed this as completed Nov 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants