Permalink
Browse files

modified the readme file and webRTC directory

  • Loading branch information...
cwgis
cwgis committed Nov 29, 2012
1 parent 8a6f66a commit 2a856a144c037cd0f3575fe8b45b5c85f231dfd1
Showing with 79 additions and 0 deletions.
  1. +3 −0 README
  2. +12 −0 applications/webRTC/index.html
  3. +64 −0 applications/webRTC/js/webrtc.js
View
3 README
@@ -0,0 +1,3 @@
+application
+===========
+The applications about HTML5 and CSS3
@@ -0,0 +1,12 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8" />
+ <title>test camera</title>
+</head>
+<body>
+ <device type="media"></device>
+ <video autoplay></video>
+ <script type="text/javascript" src="js/webrtc.js"></script>
+</body>
+</html>
@@ -0,0 +1,64 @@
+/*jslint*/
+(function () {
+ function $(selector, context) {
+ context = context || document;
+ return context.querySelector(selector);
+ };
+
+ function hasGetUserMedia() {
+ return !! (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
+ }
+
+ function update (stream) {
+ $('video').src = stream.url;
+ }
+
+ function onFailSoHard(e) {
+ console.log('Reeeejected', e)
+ }
+
+ function snapshot () {
+ if (localMediaStream) {
+ context.drawImage(video, 0, 0);
+
+ $('img').src = canvas.toDataURL('image/webp');
+ }
+ }
+
+ window.URL = window.URL || window.webkitURL;
+ navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
+
+ var video = $('video');
+ /*
+ var canvas = $('canvas');
+ var context = canvas.getContext('2d');
+ */
+ var localMediaStream = null;
+
+ if (hasGetUserMedia()) {
+ navigator.getUserMedia({video: true, audio: true}, function (stream) {
+ //var video = $('video');
+ video.src = window.URL.createObjectURL(stream);
+ localMediaStream = stream;
+
+ /*
+ video.onloadedmetadata = function () {
+ // ready to go ,do some stuff
+ };
+ */
+ }, onFailSoHard);
+
+ } else {
+ alert('getUserMedia is not supported in your browser');
+ }
+
+ // TODO:
+ /*
+ $('device').addEventListener('change', function () {
+ console.log(this.data);
+ var data = this.data;
+ update(this.data);
+ }, false);
+ */
+}());
+

0 comments on commit 2a856a1

Please sign in to comment.