Hey,
I'm using the following code to enable and disable a WebCamTexture:
// enable
_webcamTexture = new WebCamTexture (WebCamTexture.devices[_cameraIndex].name);
_webcamTexture.Play ();
// disable
_webcamTexture.Stop ();
_webcamTexture = null;
It works fine on the Editor and on WebGL. However, when I disable the WebCam on the WebGL build, the webcam light continues enabled and I' not able to disable it.
Already tried disabling it, calling a function with the following code in the browser but no luck.
if (localStream === undefined) {
var MediaStream = window.MediaStream;
if (typeof MediaStream === 'undefined' && typeof webkitMediaStream !== 'undefined') {
MediaStream = webkitMediaStream;
}
/*global MediaStream:true */
if (typeof MediaStream !== 'undefined' && !('stop' in MediaStream.prototype)) {
MediaStream.prototype.stop = function() {
this.getVideoTracks().forEach(function(track) {
track.stop();
});
};
}
} else {
localStream.getTracks().forEach(function(track) {
track.stop()
});
}
Thanks for any help.
↧