forked from samdutton/simpl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE html> | ||
|
||
<!-- | ||
Copyright 2017 Google Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<html lang="en"> | ||
<head> | ||
|
||
<meta name="description" content="Simplest possible examples of HTML, CSS and JavaScript." /> | ||
<meta name="author" content="//samdutton.com"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> | ||
<meta itemprop="name" content="simpl.info: simplest possible examples of HTML, CSS and JavaScript"> | ||
<meta itemprop="image" content="/images/icons/icon192.png"> | ||
<meta name="mobile-web-app-capable" content="yes"> | ||
<meta id="theme-color" name="theme-color" content="#fff"> | ||
|
||
<base target="_blank"> | ||
|
||
<title>getUserMedia: HD</title> | ||
|
||
<link rel="stylesheet" href="../../css/main.css" /> | ||
|
||
<style> | ||
video { | ||
object-fit: cover; | ||
} | ||
|
||
@media (min-width: 1000px) { | ||
video { | ||
height: 480px; | ||
} | ||
} | ||
</style> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<div id="container"> | ||
|
||
<h1><a href="../index.html" title="simpl.info home page">simpl.info</a> getUserMedia: HD</h1> | ||
|
||
<div id="highlight"> | ||
<p>New codelab: <a href="https://codelabs.developers.google.com/codelabs/webrtc-web">Realtime communication with WebRTC</a></p> | ||
</div> | ||
|
||
<video autoplay></video> | ||
|
||
<p>The <code>MediaStream</code> object <code>stream</code> passed to the <code>getUserMedia()</code> callback in this demo is in global scope, so you can inspect it from the console.</p> | ||
|
||
<p>This demo attempts to get video with a resolution of 1920x1080px.</p> | ||
|
||
<p>For more information, see <a href="https://www.html5rocks.com/en/tutorials/getusermedia/intro/" title="Media capture article by Eric Bidelman on HTML5 Rocks">Capturing Audio & Video in HTML5</a> on HTML5 Rocks.</p> | ||
|
||
<a href="https://github.com/samdutton/simpl/blob/gh-pages/getusermedia" title="View source for this page on GitHub" id="viewSource">View source on GitHub</a> | ||
|
||
</div> | ||
|
||
<script src="js/main.js"></script> | ||
|
||
<script src="../../js/lib/ga.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright 2017 Google Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var constraints = { | ||
video: {width: {exact: 1920}, height: {exact: 1080}} | ||
}; | ||
|
||
var video = document.querySelector('video'); | ||
|
||
function handleSuccess(stream) { | ||
window.stream = stream; // stream available to console | ||
video.src = window.URL.createObjectURL(stream); | ||
} | ||
|
||
function handleError(error) { | ||
console.log('navigator.getUserMedia error: ', error); | ||
} | ||
|
||
navigator.mediaDevices.getUserMedia(constraints). | ||
then(handleSuccess).catch(handleError); |