如何以角度从网络摄像头获取视频流
问题描述:
我需要将视频从我的网络摄像头传输到所有进入我网页的用户。如何以角度从网络摄像头获取视频流
如果我目前进入我的网页,我可以在网络摄像头看到自己,但我希望每个浏览到我的网页的用户都能看到我的直播。
我是新来的角,我在这里错过了什么?我如何向所有进入我的页面的用户进行广播?
我有这样的HTML代码:
<body>
<div ng-app="myapp" ng-controller="mainController">
<webcam channel="channel"
on-streaming="onSuccess()"
on-error="onError(err)"
on-stream="onStream(stream)">
</webcam>
<button ng-click="makeSnapshot()">take picture</button>
<canvas id="snapshot" width="300" height="300"></canvas>
</div>
<div class="webcam" ng-transclude></div>
<div id="stream" ></div>
</body>
而我的模块代码:
var webcam = angular.module('myapp', ['webcam'])
.controller('mainController', function ($scope) {
var _video = null,
patData = null;
$scope.patOpts = { x: 0, y: 0, w: 25, h: 25 };
$scope.channel = {};
$scope.webcamError = false;
$scope.onError = function (err) {
};
$scope.onSuccess = function() {
_video = $scope.channel.video;
$scope.$apply(function() {
$scope.patOpts.w = _video.width;
$scope.patOpts.h = _video.height;
$scope.showDemos = true;
});
};
$scope.onStream = function (stream) {
//i think it is here i need to add some code for streaming
};
$scope.makeSnapshot = function() {
};
$scope.downloadSnapshot = function downloadSnapshot(dataURL) {
window.location.href = dataURL;
};
var getVideoData = function getVideoData(x, y, w, h) {
};
var sendSnapshotToServer = function sendSnapshotToServer(imgBase64) {
$scope.snapshotData = imgBase64;
};
});