Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tonyjcamp/learning-getUserMedia
base: e208d80734
...
head fork: tonyjcamp/learning-getUserMedia
compare: 95d58eb6ce
Checking mergeability… Don't worry, you can still create the pull request.
  • 13 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
6 public/javascripts/application.js
@@ -53,8 +53,8 @@ var doc = document,
// will display the video with a different
// aspect ratio.
if (supportsObjectFit == true){
- VIDEO_WIDTH = 640;
- VIDEO_HEIGHT = 480;
+ VIDEO_WIDTH = 320;
+ VIDEO_HEIGHT = 240;
} else {
VIDEO_WIDTH = video.videoWidth;
VIDEO_HEIGHT = video.videoHeight;
@@ -73,7 +73,7 @@ var doc = document,
var button = document.getElementById('take'),
canvasDataUrl = canvas.toDataURL('image/png');
- button.classList.add('hidden');
+ //button.classList.add('hidden');
canvas.classList.remove('hidden');
computeSize(true);
View
6 public/stylesheets/style.css
@@ -24,14 +24,14 @@ body {
canvas {
background: #eaeaea;
display: block;
- height: 480px;
- width: 640px;
+ height: 240px;
+ width: 320px;
image-rendering: optimizeQuality;
object-fit: cover;
}
video {
- width: 640px;
+ width: 320px;
}
.hidden {
View
73 server.js
@@ -9,9 +9,10 @@ var express = require('express'),
Bird = require('bird')({
oauth_token : 'TTpJ7j4gNqpkusHXG8CA',
oauth_token_secret : '4nhHO5JCK05zNtZbdxghJqzhRegWeVjYkYz57UxIpE',
- callback: 'http://localhost:3000/callback'
+ callback: 'http://morning-samurai-5827.herokuapp.com/callback'
});
+
// shorthand server
var app = express.createServer();
@@ -81,22 +82,6 @@ app.get('/studio', function(req, res) {
});
});
-app.get('/tweet', function(req, res) {
- var options = {
- status: 'Testing Crrnt Stts!',
- media: 'h'
- };
-
- Bird.tweet(req, options, function(err, data, response) {
- if (err) {
- res.send(err);
- }
- else {
- res.send(data);
- }
- });
-});
-
app.post('/snap', function(req, res) {
var imageData = '';
@@ -107,56 +92,46 @@ app.post('/snap', function(req, res) {
req.on('end', function() {
imageData = imageData.replace(/^data:image\/png;base64,/,"");
+
+ // var buffer = '', //new Buffer(imageData, 'base64'),
+ // filename = nameFile();
+
+
var options = {
- status: 'Testing Crrnt Stts with pic!',
- media: imageData
- };
-
-
- var buffer = new Buffer(imageData, 'base64'),
- filename = nameFile();
-
- options.filename = filename;
-
- fs.writeFile(filename, buffer, function(err) {
- if (err) {
- console.log('error saving');
- }
- else {
- console.log('It saved!');
+ 'status': 'Testing, Crrnt Stts is good',
+ 'media[]': imageData
+ };
+
+ // fs.writeFile(filename, buffer, function(err) {
+ // if (err) {
+ // console.log('error saving');
+ // }
+ // else {
+ // console.log('It saved!');
Bird.tweet(req, options, function(err, data, response) {
+
if (err) {
res.send(err);
} else {
- //res.send(data);
+ res.send(data);
}
- });
- // res.send(filename);
- }
- });
-
-
-
+ });
+ //res.send(filename);
+ // }
+ // });
});
});
-app.post('/1/statuses/update_with_media.json', function() {
-
-});
-
-
function nameFile() {
var path = './public/snaps/',
- timestamp = new Date().toJSON();
+ timestamp = Math.round(new Date().getTime() / 1000);
return path + 'image_' + timestamp + '.png';
}
-
-
var port = process.env.PORT || 3000;
app.listen(port, function() {
console.log("Listening on " + port);
View
2  views/index.html
@@ -13,7 +13,7 @@
</video>
<!-- NEEDS THE DAMN WIDTH AND HEIGHT SET ON THE ELEMENT -->
- <canvas id="snapshot" width="640" height="480" class="hidden">
+ <canvas id="snapshot" width="320" height="240" class="hidden">
</canvas>
View
2  views/index.jade
@@ -1,6 +1,6 @@
video#video(autoplay="")
-canvas#snapshot.hidden(width="640", height="480")
+canvas#snapshot.hidden(width="320", height="240")
button#take Take Picture

No commit comments for this range

Something went wrong with that request. Please try again.