Skip to content

Allow user to specify media options on request. #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions dist/jpeg_camera.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JpegCamera 1.3.3 | 2016-09-18
/*! JpegCamera 1.3.3 | 2017-08-16
(c) 2013 Adam Wrobel
https://amw.github.io/jpeg_camera */
(function() {
Expand Down Expand Up @@ -266,7 +266,7 @@
}

JpegCameraHtml5.prototype._engine_init = function() {
var error, failure, get_user_media_options, horizontal_padding, success, that, vertical_padding;
var default_media_options, error, failure, get_user_media_options, horizontal_padding, success, that, vertical_padding;
this._debug("Using HTML5 engine");
vertical_padding = Math.floor(this.view_height * 0.2);
horizontal_padding = Math.floor(this.view_width * 0.2);
Expand Down Expand Up @@ -302,7 +302,7 @@
this._load_shutter_sound(this.options.shutter_mp3_url);
}
}
get_user_media_options = {
default_media_options = {
video: {
optional: [
{
Expand All @@ -317,6 +317,11 @@
]
}
};
if (typeof this.options.get_media_options === 'function') {
get_user_media_options = this.options.get_media_options(default_media_options);
} else {
get_user_media_options = default_media_options;
}
that = this;
success = function(stream) {
that._remove_message();
Expand Down
4 changes: 2 additions & 2 deletions dist/jpeg_camera.min.js

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions dist/jpeg_camera_no_flash.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JpegCamera 1.3.3 | 2016-09-18
/*! JpegCamera 1.3.3 | 2017-08-16
(c) 2013 Adam Wrobel
https://amw.github.io/jpeg_camera */
(function() {
Expand Down Expand Up @@ -266,7 +266,7 @@
}

JpegCameraHtml5.prototype._engine_init = function() {
var error, failure, get_user_media_options, horizontal_padding, success, that, vertical_padding;
var default_media_options, error, failure, get_user_media_options, horizontal_padding, success, that, vertical_padding;
this._debug("Using HTML5 engine");
vertical_padding = Math.floor(this.view_height * 0.2);
horizontal_padding = Math.floor(this.view_width * 0.2);
Expand Down Expand Up @@ -302,7 +302,7 @@
this._load_shutter_sound(this.options.shutter_mp3_url);
}
}
get_user_media_options = {
default_media_options = {
video: {
optional: [
{
Expand All @@ -317,6 +317,11 @@
]
}
};
if (typeof this.options.get_media_options === 'function') {
get_user_media_options = this.options.get_media_options(default_media_options);
} else {
get_user_media_options = default_media_options;
}
that = this;
success = function(stream) {
that._remove_message();
Expand Down
4 changes: 2 additions & 2 deletions dist/jpeg_camera_no_flash.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/jpeg_camera_with_dependencies.min.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/jpeg_camera_html5.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if navigator.getUserMedia
else if can_play mpeg_audio
@_load_shutter_sound @options.shutter_mp3_url

get_user_media_options =
default_media_options =
video:
optional: [
{minWidth: 1280},
Expand All @@ -82,6 +82,11 @@ if navigator.getUserMedia
{minWidth: 360}
]

if typeof @options.get_media_options is 'function'
get_user_media_options = @options.get_media_options default_media_options
else
get_user_media_options = default_media_options

that = this
success =
(stream) ->
Expand Down