Skip to content

Instantly share code, notes, and snippets.

@sole
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sole/9234924 to your computer and use it in GitHub Desktop.
Save sole/9234924 to your computer and use it in GitHub Desktop.
/*var detectOrientation = function () {
if (window.matchMedia('(orientation: landscape)').matches) {
videoWidth = 135;
videoHeight = 101;
console.log('landscape mode');
} else {
videoWidth = 101;
videoHeight = 135;
console.log('portrait mode');
}
};
detectOrientation();
*/
if (navigator.getMedia) {
svg = $('<svg class="progress" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 128 64" preserveAspectRatio="xMidYMid" hidden><path d="M0,0 " id="arc" fill="none" stroke="rgba(226,38,97,0.8)" /></svg>');
footer.prepend(svg);
gumHelper.startVideoStreaming(function callback(err, stream, videoElement, videoWidth, videoHeight) {
if (err) {
disableVideoMode();
} else {
detectOrientation();
console.log('current width/height ', videoWidth, videoHeight);
var finalWidth, finalHeight;
finalWidth = 135;
if(videoWidth > videoHeight) {
finalHeight = finalWidth * videoHeight / videoWidth;
} else {
finalHeight = finalWidth * videoWidth / videoHeight;
}
videoElement.width = finalWidth;
videoElement.height = finalHeight;
footer.prepend(videoElement);
videoElement.play();
videoShooter = new VideoShooter(videoElement);
composer.form.click();
}
});
} else {
disableVideoMode();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment