The camera plugin allows to capture images with your computer webcam or phone camera. Works only on the browsers that support the Stream Api.
HTML:
<!-- Camera button -->
<button type="button" class="camera-show">Camera</button>
<!-- Camera container -->
<div class="camera-container" style="display: none;">
<div class="camera-preview"></div>
<button type="button" class="camera-hide">Cancel</button>
<button type="button" class="camera-capture">Take picture</button>
</div>
JavaScript:
<script src="assets/js/filepicker-camera.js"></script>
$('#filepicker').filePicker({
// options...
plugins: ['camera'], // <=
camera: {
showBtn: $('.camera-show'),
container: $('.camera-container'),
}
});
Requires Bootstrap.
HTML:
<!-- Camera button -->
<button type="button" class="btn btn-info camera-show">Camera</button>
<!-- Camera Modal -->
<div id="camera-modal" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<span class="close" data-dismiss="modal">×</span>
<h4 class="modal-title">Take a picture</h4>
</div>
<div class="modal-body">
<div class="camera-preview"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left camera-hide"
data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success camera-capture">Take picture</button>
</div>
</div>
</div>
</div>
JavaScript:
<script src="assets/js/filepicker-camera.js"></script>
$('#filepicker').filePicker({
// options...
plugins: ['camera'], // <=
});
The camera plugin options must be passed inside the camera
object:
$('#filepicker').filePicker({
// options...
camera: {
flipHorizontal: false,
// more camera options
}
}
});
The jQuery object for the camera container or Bootstrap modal.
- Type: jQuery Object
- Default:
$('#camera-modal')
The jQuery object for the camera preview.
- Type: jQuery Object
- Default:
container.find('.camera-preview')
The jQuery object for the button that shows the camera container / modal.
- Type: jQuery Object
- Default:
element.find('.camera-show')
The jQuery object for the button that hides the camera container / modal.
- Type: jQuery Object
- Default:
container.find('.camera-hide')
The jQuery object for the button that captures the image.
- Type: jQuery Object
- Default:
container.find('.camera-capture')
The getUserMedia video constraints.
- Type: Object
- Default:
{}
Whether to flip the camera horizontal.
- Type: Boolean
- Default:
true
An object of selectors.
- Type: Object
- Default:
{
show: '.camera-show',
hide: '.camera-hide',
container: '#camera-modal',
capture: '.camera-capture',
preview: '.camera-preview'
}
The camera fallback handler.
/**
* @param {Object} e
* @param {String} message
*/
camerafallback: function (e, message) { }
The camera capture handler.
/**
* @param {Object} e
* @param {Object} data
*/
cameracapture: function (e, data) { }
The camera success handler.
/**
* @param {Object} e
* @param {MediaStream} stream
*/
camerasuccess: function (e, stream) { }
The camera error handler.
/**
* @param {Object} e
* @param {Object} error
*/
cameraerror: function (e, error) { }