Skip to content

Latest commit

 

History

History
116 lines (105 loc) · 3.68 KB

gum.md

File metadata and controls

116 lines (105 loc) · 3.68 KB
layout title
page
getUserMedia constraints · RoomRTC

{% raw %}

<style> video { background: none; height: auto; width: auto; } </style>
 

{% endraw %} <script src="{{ site.baseurl }}/latest/roomrtc.min.js"></script> <script src="{{ site.baseurl }}/latest/angular-v1.4.9.js"></script> <script type="text/javascript"> angular.module("demo", []) .controller("roomController", function ($scope, $timeout, $sce) { $scope.localVideo = null; var qvgaConstraints = { video: { mandatory: { maxWidth: 320, maxHeight: 180 } } }; var vgaConstraints = { video: { mandatory: { maxWidth: 640, maxHeight: 360 } } }; var hdConstraints = { video: { mandatory: { minWidth: 1280, minHeight: 720 } } }; var roomrtc = new RoomRTC(); var video = document.querySelector('video'); video.addEventListener('play', function() { $timeout(function() { $scope.dimensions = 'Actual video dimensions: ' + video.videoWidth + 'x' + video.videoHeight + 'px.'; }, 500); }); /** * Setup control buttons * */ $scope.stop = function () { $scope.localVideo = null; roomrtc.stop(); } $scope.qvga = function () { $scope.stop(); roomrtc.initMediaSource(qvgaConstraints).then(stream => { var streamUrl = roomrtc.getStreamAsUrl(stream); $timeout(function () { $scope.localVideo = $sce.trustAsResourceUrl(streamUrl); }); }).catch((err) => { console.log('GUM ERROR:', err) }) } $scope.vga = function () { $scope.stop(); roomrtc.initMediaSource(vgaConstraints).then(stream => { var streamUrl = roomrtc.getStreamAsUrl(stream); $timeout(function () { $scope.localVideo = $sce.trustAsResourceUrl(streamUrl); }); }).catch((err) => { console.log('GUM ERROR:', err) }) } $scope.hd = function () { $scope.stop(); roomrtc.initMediaSource(hdConstraints).then(stream => { var streamUrl = roomrtc.getStreamAsUrl(stream); $timeout(function () { $scope.localVideo = $sce.trustAsResourceUrl(streamUrl); }); }).catch((err) => { console.log('GUM ERROR:', err) }) } }); </script>