Permalink
Browse files

Firefox support

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information...
1 parent b75b737 commit dbace2d2961c66f0b7401057f3b23a80bfc7b1f5 @rwaldron committed Aug 20, 2012
View
@@ -40,12 +40,18 @@ var // Program initializers
// Store datauri's received from stream
this.dataUri = "";
- navigator.getUserMedia({ video: true, audio: true }, function( raw, stream ) {
- //getUserMedia("video, audio", function( stream ) {
- // Attach user media stream to video container source
- this.media.src = raw.currentTime !== undefined ? raw : stream;
+ navigator.getUserMedia({
+ video: true
+ }, function( raw ) {
+ var stream;
+
+ if ( raw.label && raw.readyState === 1 ) {
+ stream = window.URL.createObjectURL( raw );
+ }
+ // Attach user media stream to video container source
+ this.media.src = stream && stream || raw;
this.media.play();
// When video signals that it has loadedmetadata, begin "playing"
@@ -58,7 +64,10 @@ var // Program initializers
this.draw();
}.bind(this), false);
- }.bind(this));
+ }.bind(this),
+ function() {
+ console.log(arguments);
+ });
};
Operator.prototype.draw = function() {
@@ -148,7 +157,14 @@ var // Program initializers
this.listen( DMV.operator.media );
},
listen: function( media ) {
- media.addEventListener( "click", DMV.operator.capture.bind( DMV.operator ), false );
+
+ if ( !media ) {
+ setTimeout(function() {
+ DMV.listen(media);
+ }, 10);
+ } else {
+ media.addEventListener( "click", DMV.operator.capture.bind( DMV.operator ), false );
+ }
}
};
@@ -1,19 +0,0 @@
-Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
@@ -1,50 +0,0 @@
-# mime
-
-Support for mapping between file extensions and MIME types. This module uses the latest version of the Apache "mime.types" file (maps over 620 types to 800+ extensions). It is also trivially easy to add your own types and extensions, should you need to do that.
-
-## Install
-
-Install with [npm](http://github.com/isaacs/npm):
-
- npm install mime
-
-## API - Queries
-
-### mime.lookup(path)
-Get the mime type associated with a file. This is method is case-insensitive. Everything in path up to and including the last '/' or '.' is ignored, so you can pass it paths, filenames, or extensions, like so:
-
- var mime = require('mime');
-
- mime.lookup('/path/to/file.txt'); // => 'text/plain'
- mime.lookup('file.txt'); // => 'text/plain'
- mime.lookup('.txt'); // => 'text/plain'
- mime.lookup('htm'); // => 'text/html'
-
-### mime.extension(type) - lookup the default extension for type
-
- mime.extension('text/html'); // => 'html'
- mime.extension('application/octet-stream'); // => 'bin'
-
-### mime.charsets.lookup() - map mime-type to charset
-
- mime.charsets.lookup('text/plain'); // => 'UTF-8'
-
-(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)
-
-## API - Customizing
-
-The following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/bentomas/node-mime/wiki/Requesting-New-Types).
-### mime.define() - Add custom mime/extension mappings
-
- mime.define({
- 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
- 'application/x-my-type': ['x-mt', 'x-mtt'],
- // etc ...
- });
-
- mime.lookup('x-sft'); // => 'text/x-some-format'
- mime.extension('text/x-some-format'); // => 'x-sf'
-
-### mime.load(filepath) - Load mappings from an Apache ".types" format file
-
- mime.load('./my_project.types');
@@ -1,92 +0,0 @@
-var path = require('path'),
- fs = require('fs');
-
-var mime = module.exports = {
- /** Map of extension to mime type */
- types: {},
-
- /** Map of mime type to extension */
- extensions :{},
-
- /**
- * Define mimetype -> extension mappings. Each key is a mime-type that maps
- * to an array of extensions associated with the type. The first extension is
- * used as the default extension for the type.
- *
- * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
- *
- * @param map (Object) type definitions
- */
- define: function(map) {
- for (var type in map) {
- var exts = map[type];
-
- for (var i = 0; i < exts.length; i++) {
- mime.types[exts[i]] = type;
- }
-
- // Default extension is the first one we encounter
- if (!mime.extensions[type]) {
- mime.extensions[type] = exts[0];
- }
- }
- },
-
- /**
- * Load an Apache2-style ".types" file
- *
- * This may be called multiple times (it's expected). Where files declare
- * overlapping types/extensions, the last file wins.
- *
- * @param file (String) path of file to load.
- */
- load: function(file) {
- // Read file and split into lines
- var map = {},
- content = fs.readFileSync(file, 'ascii'),
- lines = content.split(/[\r\n]+/);
-
- lines.forEach(function(line, lineno) {
- // Clean up whitespace/comments, and split into fields
- var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
- map[fields.shift()] = fields;
- });
-
- mime.define(map);
- },
-
- /**
- * Lookup a mime type based on extension
- */
- lookup: function(path, fallback) {
- var ext = path.replace(/.*[\.\/]/, '').toLowerCase();
- return mime.types[ext] || fallback || mime.default_type;
- },
-
- /**
- * Return file extension associated with a mime type
- */
- extension: function(mimeType) {
- return mime.extensions[mimeType];
- },
-
- /**
- * Lookup a charset based on mime type.
- */
- charsets: {
- lookup: function (mimeType, fallback) {
- // Assume text types are utf8. Modify mime logic as needed.
- return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
- }
- }
-};
-
-// Load our local copy of
-// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
-mime.load(path.join(__dirname, 'types/mime.types'));
-
-// Overlay enhancements submitted by the node.js community
-mime.load(path.join(__dirname, 'types/node.types'));
-
-// Set the default type
-mime.default_type = mime.types.bin;
@@ -1,22 +0,0 @@
-{
- "author": {
- "name": "Robert Kieffer",
- "url": "http://github.com/broofa",
- "email": "robert@broofa.com"
- },
- "contributors": [
- {
- "name": "Benjamin Thomas",
- "url": "http://github.com/bentomas",
- "email": "benjamin@benjaminthomas.org"
- }
- ],
- "dependencies": {},
- "description": "A comprehensive library for mime-type mapping",
- "devDependencies": {"async_testing": ""},
- "keywords": ["util", "mime"],
- "main": "mime.js",
- "name": "mime",
- "repository": {"url": "http://github.com/bentomas/node-mime", "type": "git"},
- "version": "1.2.4"
-}
@@ -1,79 +0,0 @@
-/**
- * Requires the async_testing module
- *
- * Usage: node test.js
- */
-var mime = require('./mime');
-exports["test mime lookup"] = function(test) {
- // easy
- test.equal('text/plain', mime.lookup('text.txt'));
-
- // hidden file or multiple periods
- test.equal('text/plain', mime.lookup('.text.txt'));
-
- // just an extension
- test.equal('text/plain', mime.lookup('.txt'));
-
- // just an extension without a dot
- test.equal('text/plain', mime.lookup('txt'));
-
- // default
- test.equal('application/octet-stream', mime.lookup('text.nope'));
-
- // fallback
- test.equal('fallback', mime.lookup('text.fallback', 'fallback'));
-
- test.finish();
-};
-
-exports["test extension lookup"] = function(test) {
- // easy
- test.equal('txt', mime.extension(mime.types.text));
- test.equal('html', mime.extension(mime.types.htm));
- test.equal('bin', mime.extension('application/octet-stream'));
-
- test.finish();
-};
-
-exports["test mime lookup uppercase"] = function(test) {
- // easy
- test.equal('text/plain', mime.lookup('TEXT.TXT'));
-
- // just an extension
- test.equal('text/plain', mime.lookup('.TXT'));
-
- // just an extension without a dot
- test.equal('text/plain', mime.lookup('TXT'));
-
- // default
- test.equal('application/octet-stream', mime.lookup('TEXT.NOPE'));
-
- // fallback
- test.equal('fallback', mime.lookup('TEXT.FALLBACK', 'fallback'));
-
- test.finish();
-};
-
-exports["test custom types"] = function(test) {
- test.equal('application/octet-stream', mime.lookup('file.buffer'));
- test.equal('audio/mp4', mime.lookup('file.m4a'));
-
- test.finish();
-};
-
-exports["test charset lookup"] = function(test) {
- // easy
- test.equal('UTF-8', mime.charsets.lookup('text/plain'));
-
- // none
- test.ok(typeof mime.charsets.lookup(mime.types.js) == 'undefined');
-
- // fallback
- test.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
-
- test.finish();
-};
-
-if (module == require.main) {
- require('async_testing').run(__filename, process.ARGV);
-}
Oops, something went wrong.

0 comments on commit dbace2d

Please sign in to comment.