forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
18
Kha/Backends/HTML5/kha/capture/VideoCapture.hx
Normal file
18
Kha/Backends/HTML5/kha/capture/VideoCapture.hx
Normal file
@ -0,0 +1,18 @@
|
||||
package kha.capture;
|
||||
|
||||
import js.Browser;
|
||||
|
||||
class VideoCapture {
|
||||
public static function init(initialized: kha.Video->Void, error: Void->Void): Void {
|
||||
var getUserMedia = untyped __js__("navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia");
|
||||
getUserMedia.call(js.Browser.navigator, {audio: true, video: true}, function(stream: Dynamic) {
|
||||
var element: js.html.VideoElement = cast Browser.document.createElement("video");
|
||||
element.srcObject = stream;
|
||||
element.onloadedmetadata = function(e) {
|
||||
initialized(kha.js.Video.fromElement(element));
|
||||
}
|
||||
}, function() {
|
||||
error();
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user